编写 flutter 代码碰到一个错误

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
BoxConstraints forces an infinite width.These invalid constraints were provided to _RenderColoredBox's layout() function by the following function, which probably computed the invalid constraints in question:RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:268:14)
The offending constraints were: BoxConstraints(w=Infinity, h=44.0)
The relevant error-causing widget was: Container file:///Users/project_github/flutter/my_flutter_demo/lib/error_page.dart:20:20
When the exception was thrown, this was the stack:
#0      BoxConstraints.debugAssertIsValid.<anonymous closure>.throwError (package:flutter/src/rendering/box.dart:517:9)
#1      BoxConstraints.debugAssertIsValid.<anonymous closure> (package:flutter/src/rendering/box.dart:559:21)
#2      BoxConstraints.debugAssertIsValid (package:flutter/src/rendering/box.dart:565:6)
#3      RenderObject.layout (package:flutter/src/rendering/object.dart:1677:24)
#4      RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:268:14)
...
The following RenderObject was being processed when the exception was fired: RenderConstrainedBox#e8eb9 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  parentData: bottom=0.0; offset=Offset(0.0, 515.0) (can use size)
...  constraints: BoxConstraints(unconstrained)
...  size: Size(360.0, 44.0)
...  additionalConstraints: BoxConstraints(w=Infinity, h=44.0)
RenderObject: RenderConstrainedBox#e8eb9 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATEparentData: bottom=0.0; offset=Offset(0.0, 515.0) (can use size)constraints: BoxConstraints(unconstrained)size: Size(360.0, 44.0)additionalConstraints: BoxConstraints(w=Infinity, h=44.0)
...  child: _RenderColoredBox#4f7c5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: <none> (can use size)
...    constraints: BoxConstraints(w=360.0, h=44.0)
...    size: Size(360.0, 44.0)
...    behavior: opaque
...    child: RenderPositionedBox#c8a6c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(w=360.0, h=44.0)
...      size: Size(360.0, 44.0)
...      alignment: center
...      textDirection: ltr
...      widthFactor: expand
...      heightFactor: expand
...      child: RenderParagraph#2f2e8 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(152.0, 11.5) (can use size)
...        constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=44.0)
...        size: Size(56.0, 21.0)
...        textAlign: start
...        textDirection: ltr
...        softWrap: wrapping at box width
...        overflow: clip
...        locale: en_US
...        maxLines: unlimited
...        text: TextSpan
...          debugLabel: ((englishLike body1 2014).merge(blackMountainView bodyText2)).merge(unknown)
...          inherit: false
...          color: Color(0xff000000)
...          family: Roboto
...          size: 14.0
...          weight: 500
...          baseline: alphabetic
...          decoration: TextDecoration.none
...          "确认"
====================================================================================================

我的代码

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';class ErrorPage extends StatefulWidget {@override_MyErrorPageState createState() => _MyErrorPageState();}class _MyErrorPageState extends State<ErrorPage> {@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text("测试页面"),),body: Stack(children: [Positioned(bottom: 0,child: Container(color: Colors.green,width: double.infinity,height: 44,alignment: Alignment.center,child: Text("确认",style: TextStyle(color: Colors.black,fontSize: 14,fontWeight: FontWeight.w500),),))],));}}

解决办法

给Positioned 设置一个宽度即可

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';class ErrorPage extends StatefulWidget {@override_MyErrorPageState createState() => _MyErrorPageState();
}class _MyErrorPageState extends State<ErrorPage> {@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text("测试页面"),),body: Stack(children: [Positioned(bottom: 0,width: MediaQuery.of(context).size.width,//给 Positioned 设置一个宽度即可child: Container(color: Colors.green,width: double.infinity,height: 44,alignment: Alignment.center,child: Text("确认",style: TextStyle(color: Colors.black,fontSize: 14,fontWeight: FontWeight.w500),),))],));}
}

http://www.taodudu.cc/news/show-4111452.html

相关文章:

  • 使用Java串口操作RXTX,报错 no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver解决方案
  • Kafka创建topic报错:Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already
  • This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错
  • SpringBoot整合redis,启动提示错误信息: An exception was thrown by org.redisson.misc.RedissonPromise$$Lambda$682
  • Exception thrown from ApplicationListener handling ContextClosedEvent
  • java unhandled,Unhandled Exception thrown: class java.lang.ClassCastException
  • Flutter开发:Another exception was thrown:Unable to load asset:…的解决方法
  • ajax errorthrown属性,【技术】error:function (XMLHttpRequest, textStatus, errorThrown)
  • 抛出异常关键字throw与定义异常关键字throws
  • java 篮球队淘汰赛冠军_《黑白2》口袋世界淘汰赛挑战各馆主冠军方法
  • 背壳BAKAZU 2013复古邮差风帆布休闲潮男腰包 A801BK 黑色 腰包胸包【图片 价格 品牌 报价】-京东商城...
  • 企业网站常见误区-金瑞帆高端建站
  • 海上的帆
  • 无所不能,传感器黑科技层出不穷
  • 岭南的一艘 “海盗船” 出海时扬起了单机游戏的帆
  • HTML5之帆布(canvas)(三)
  • 如何用python画帆船_简单几步,100行代码用Python画一个蝙蝠侠的logo
  • HTML5之帆布(canvas)(一)
  • 菜鸡帆并不算长の编程之旅回顾
  • c语言程序设计第07章在线测,《C语言程序设计》第07章在线测试.doc
  • 2022-07-17 第四小组 孙翰章 职业规划
  • 24第六季四小时首播进入倒计时!
  • 非同帆响-得帆信息发布全新高生产力PaaS平台,重新定义企业软件生产力
  • 2021-08-05 得帆技术培训Linux作业
  • 7金5银,中国跳水梦之队背后的“黑科技“是什么?
  • STM32cubIDE 黑色主题_儿童画创意第二弹 | 绘画的秘密+万圣节主题画,10个创意教程一次看完!...
  • 杨伟帆的个人简历
  • 实验四+049+尤帆贤
  • 维京传奇第四季/全集Vikings迅雷下载
  • 黑帆第一季/全集Black Sails迅雷下载

Flutter 布局报错The following assertion was thrown during performLayout():相关推荐

  1. Flutter开发:报错The following assertion was thrown resolving an image codec:Unable to…的解决方法

    前言 在Flutter开发中,经常会遇到一些稀奇古怪的的报错,比如版本更新之后会报错.文件没有导入会报错.第三方插件版本不一致的报错等等,而且最近几年Flutter不断完善和更新的速度越来越快,这就需 ...

  2. 【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )

    文章目录 一.报错信息 二.解决方案 一.报错信息 Flutter 应用运行时报如下错误 : Launching lib\main.dart on Pixel 2 in debug mode... R ...

  3. 【错误记录】Flutter 组件报错 ( No Directionality widget found. | RichText widgets require a Directionality )

    文章目录 一.报错信息 二.解决方案 一.报错信息 报错信息 : Performing hot reload... Syncing files to device Pixel 2... Reloade ...

  4. 【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )

    文章目录 一.报错信息 二.问题分析 三.解决方案 一.报错信息 参考 [Flutter]Flutter Gallery 官方示例简介 博客 ; Flutter Galley 开源项目运行时 , 部署 ...

  5. 【错误记录】Flutter 构建报错 ( Because xxx requires SDK version >=2.12.0-0 <3.0.0, versio | Dart SDK 版本低 )

    文章目录 一.报错信息 二.问题分析 三.解决方案 一.报错信息 event sent after app closed: {id: 0, progressId: null, message: Run ...

  6. 【错误记录】Flutter / Android 报错 ( AAPT: error: attribute android:requestLegacyExternalStorage not found )

    文章目录 一. 报错信息 二. 问题分析 三. 解决方案 一. 报错信息 Flutter 使用 image_picker 时 , 需要进行 AndroidX 兼容 , 设置了 Android 编译 S ...

  7. 【错误记录】Flutter 运行报错 Error -32000 received from application: There are no running service protocol

    文章目录 一. 报错信息 二. 解决方案 1. 解决方案一 2. 解决方案二 ( 推荐 ) 一. 报错信息 在 Android Studio 中运行 Flutter 程序 , 点击 按钮运行程序 , ...

  8. 运行报错error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

    问题cv2.resize()报错 cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\imgproc\src\resiz ...

  9. tensorrt报错 [F] [TRT] Assertion failed: Unsupported SM.

    目录 0. 完整报错信息 1. 原因 0. 完整报错信息 在安装完tensorRT,运行minist测试用例时,发生如下报错 &&&& RUNNING TensorRT ...

  10. 【错误记录】Flutter 编译报错 ( The parameter ‘‘ can‘t have a value of ‘null‘ because of its type, but the im )

    文章目录 一.报错信息 二.解决方案 一.报错信息 打开了一个去年写的 Flutter 项目 , 发现直接报错 ; The parameter 'icon' can't have a value of ...

最新文章

  1. html5网页仿写,纯CSS代码模仿绘制蚂蚁庄园页面
  2. iOS 总结遇到的各种坑儿
  3. 进程间通信(6) 邮槽
  4. NSUserDefault 的使用
  5. .deploy 文件 php,关于php:Heroku deploy自动删除服务器文件?
  6. c语言for循环的省略写法,C语言两种for循环写法分析
  7. Android WebView Error – Uncaught TypeError: Cannot call method ‘getItem’ of null at
  8. 全球首发!惯性导航导论(剑桥大学)第一部分
  9. 并发编程-------操作系统的发展
  10. [小问题笔记(八)] 常用SQL(读字段名,改字段名,打印影响行数,添加默认值,查找存储过程等)...
  11. 图解CNN十大算法架构
  12. BeX5创建w文件窗口显示不齐
  13. laravel的elixir和gulp用来对前端施工
  14. 2021年中国影院行业发展现状:院线影院规模集中度持续增强,票房前五名排名保持稳固[图]
  15. 极限中0除以常数_考研数学极限重难点讲解003期【无穷小量和无穷大量】
  16. [转]144P /240P/360P/480P/720P/1080P分辨率的差别
  17. 酷炫的可视化工具包 - cufflinks
  18. Boostnote是什么?-是为程序员开发的一种开放源代码记事本
  19. mac 在调度中心关闭软件
  20. 堆排序(最小堆)C++

热门文章

  1. 虚拟机Linux下如何查看自己的IP地址
  2. lone warrior
  3. 项目管理所有计算公式
  4. 通过数据告诉你centos和debian哪个好?
  5. 宁皓网ninghao.net这个人的教程不错
  6. 基于多角度SAR的目标三维几何信息提取技术
  7. Permission denied: user=10273, access=WRITE, inode=“/cou/jd_phone_list“:root:supergroup:-rw-r--r--
  8. Linux常用命令|徐奥雯编辑整理|XUAOWEN
  9. 精心分享8个让人大开眼界的软件和网站,极大提高办公效率
  10. 已解决报错UnboundLocalError: local variable ‘title‘ referenced before assignment