- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在尝试创建一个 ListView,但是当我导入 list_form.dart 类时出现此错误。也许我在布局上犯了一些错误,因为如果我尝试在主文件中运行它,我不会收到这个错误。
这是错误:
I/flutter (12956): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (12956): The following assertion was thrown during performResize():
I/flutter (12956): Vertical viewport was given unbounded height.
I/flutter (12956): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter (12956): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (12956): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (12956): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (12956): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (12956): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (12956): the height of the viewport to the sum of the heights of its children.
I/flutter (12956):
I/flutter (12956): When the exception was thrown, this was the stack:
I/flutter (12956): #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1133:15)
I/flutter (12956): #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1186:6)
I/flutter (12956): #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1616:9)
I/flutter (12956): #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #13 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #15 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #19 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
I/flutter (12956): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #21 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
I/flutter (12956): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #23 RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:381:13)
I/flutter (12956): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #25 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:141:11)
I/flutter (12956): #26 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (12956): #27 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:211:7)
I/flutter (12956): #28 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:355:14)
I/flutter (12956): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #33 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1192:11)
I/flutter (12956): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #36 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #37 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #38 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1192:11)
I/flutter (12956): #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #40 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #45 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #46 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #52 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #53 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #54 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #55 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2884:13)
I/flutter (12956): #56 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #57 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:520:15)
I/flutter (12956): #58 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #59 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #60 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #61 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #62 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #63 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #64 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #65 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #66 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #67 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #68 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #69 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
I/flutter (12956): #70 RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
I/flutter (12956): #71 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
I/flutter (12956): #72 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1506:7)
I/flutter (12956): #73 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:765:18)
I/flutter (12956): #74 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
I/flutter (12956): #75 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:674:13)
I/flutter (12956): #76 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter (12956): #77 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (12956): #78 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (12956): #79 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter (12956): #81 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (12956): #82 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (12956): #83 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (12956): (elided one frame from package dart:async)
I/flutter (12956):
I/flutter (12956): The following RenderObject was being processed when the exception was fired:
I/flutter (12956): RenderViewport#925a8 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12956): creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#8e8f7] ← Semantics ← Listener ←
I/flutter (12956): _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#67ae5] ←
I/flutter (12956): _ScrollSemantics-[GlobalKey#17eb8] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter (12956): NotificationListener<ScrollNotification> ← ⋯
I/flutter (12956): parentData: <none> (can use size)
I/flutter (12956): constraints: BoxConstraints(unconstrained)
I/flutter (12956): size: MISSING
I/flutter (12956): axisDirection: down
I/flutter (12956): crossAxisDirection: right
I/flutter (12956): offset: ScrollPositionWithSingleContext#c4917(offset: 0.0, range: null..null, viewport: null,
I/flutter (12956): ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#2fecf,
I/flutter (12956): ScrollDirection.idle)
I/flutter (12956): anchor: 0.0
I/flutter (12956): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (12956): RenderSliverPadding#74d62 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12956): RenderSliverList#5c56d NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12956): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderViewport#925a8 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderViewport#925a8 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#8bbda relayoutBoundary=up11 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#209b4 relayoutBoundary=up10 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a9641 relayoutBoundary=up9 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#9f5b4 relayoutBoundary=up8 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#47944 relayoutBoundary=up7 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#e17a8 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#a2328 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#02607 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: RenderBox was not laid out: RenderFlex#79164 relayoutBoundary=up3 NEEDS-PAINT
I/flutter (12956): Another exception was thrown: 'package:flutter/src/rendering/shifted_box.dart': Failed assertion: line 310 pos 12: 'child.hasSize': is not true.
I/flutter (12956): Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
这是 list_form.dart 类:
import 'package:flutter/material.dart';
class ListForm extends StatefulWidget {
@override
ListFormState createState() => new ListFormState();
}
class ListFormState extends State<ListForm> {
List<String> products = ["Test1", "Test2", "Test3"];
@override
Widget build(BuildContext context) {
return new Container(
child: new Center(
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new ListView.builder(
itemCount: products.length,
itemBuilder: (BuildContext ctxt, int index) {
return new Text(products[index]);
}
),
new IconButton(
icon: Icon(Icons.remove_circle),
onPressed: () { },
)
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
new TextField(
decoration: new InputDecoration(
hintText: "Prodotto"
),
onSubmitted: (String str) {
setState(() {
products.add(str);
});
},
),
]
)
)
);
}
}
这是 app_base.dart 类:
import 'package:flutter/material.dart';
import '../UI/list_form.dart';
class AppBase extends StatefulWidget {
@override
State createState() => new AppBaseState();
}
class AppBaseState extends State<AppBase> {
bool _pressed = true;
@override
Widget build(BuildContext context) {
return new Material(
color: Colors.greenAccent,
child: new Scaffold(
body:
new ListForm(),
appBar: AppBar(
centerTitle: true,
title: const Text('Skeeper'),
backgroundColor: Colors.green,
),
floatingActionButton: FloatingActionButton(
tooltip: 'Test',
child: new Icon(Icons.add),
backgroundColor: Colors.green,
onPressed: () {
setState(() {
_pressed = !_pressed;
});
},
),
)
);
}
}
如果有一些未使用的代码,请不要担心,这是一项正在进行的工作,这个错误只是阻止我继续我正在做的事情。
最佳答案
问题是您将 ListView
放在列/行中。异常中的文本很好地解释了错误。
为避免错误,您需要在 ListView
里面提供一个大小。
我向您推荐这段代码,它使用 Expanded
来告知 height 的水平尺寸(最大可用)和
SizedBox
(可能是一个容器) :
new Row(
children: <Widget>[
Expanded(
child: SizedBox(
height: 200.0,
child: new ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: products.length,
itemBuilder: (BuildContext ctxt, int index) {
return new Text(products[index]);
},
),
),
),
new IconButton(
icon: Icon(Icons.remove_circle),
onPressed: () {},
),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
)
,
关于dart - Flutter:RenderBox 没有布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52801201/
我正在尝试从flutter应用程序构建apk,但出现此错误: Note: /mnt/Software/Linux/Flutter/flutter/.pub-cache/hosted/pub.dartl
我有一个名为 X 的较大应用程序,还有另一个名为 Y 的较小应用程序。他们现在彼此分开,并且工作正常。我想将应用程序 Y 集成到 X 中。我想将 Y 的代码放入 X 项目中,但它们应该有不同的 Mai
在android Studio中选择Create New Flutter Project,出现如下4个选项。 Flutter 应用程序 Flutter 插件 Flutter 包 flutter 模块
我看到我的 flutter 项目生成了一个文件 ios/Flutter/Flutter.podspec ,这个文件有什么用? 如果它与生成的 Flutter.framework 有关? 我应该将它包含
我尝试过的 在包含flutter SDK的位置添加/编辑.bash_profile.rtf文件。 导出PATH = / Users / temur / Documents / Projects / F
Flutter 日志会打印数千个详细/垃圾邮件日志。 我正在尝试调试一个复杂的应用程序,但是打印太冗长了,以至于我很难找到我自己打印的东西。 有没有办法禁用详细? 就像是: Logger.level.
在flutter 1.22更新之后,我在Lineargradient colors属性中遇到错误,这给我一个错误,即未定义名称colors参数。.在Android中更新flutter和flutter插
在下面的代码 widget.hintText 中给出错误,我试图将日期选择器作为单独的组件,并在从其他文件调用它时动态传递提示文本值。 import 'package:date_field/date_
在下面的代码 widget.hintText 中给出错误,我试图将日期选择器作为单独的组件,并在从其他文件调用它时动态传递提示文本值。 import 'package:date_field/date_
Flutter 1.0 发布后,我正在按照步骤搭建 Flutter 开发环境。 在步骤中(如所附屏幕截图所示),它说要更新 $PATH 两次,一次使用 flutter 工具的路径 export PAT
我有一个用 flutter 编写的移动应用程序,我想将其转换为 flutter_web 应用程序(集成 flutter_web 尚不可用)。我目前遇到包裹问题。 我已按照本网站中列出的说明进行操作 h
如何向我的 Flutter 路由添加自定义转换?这是我目前的路线结构。 class MyApp extends StatelessWidget { // This widget is the
我正在尝试通过 URL 在 webview 中显示网页。我试过 flutter_webview_plugin 插件,但是当我在浏览器上运行项目时它不起作用。 在 flutter web applica
我正在使用 animatedContainer 在按下按钮时显示 listView.builder()。这是一个要显示的简单子(monad)列表,但问题是我不知道 ListView 构建器的高度会传递
我目前正在我的应用程序中制作渐变背景动画......我正在使用 lottie 动画的帮助下这样做!我试图将它封装在一个容器中并成功地做到了。但是有一个问题,尽管我将高度更改为大于 2000 的东西,但
美好的一天! 我无法弄清楚如何使用 google 标签管理器设置 flutter。我找到了 this package包括标签管理器 api。但是我不知道如何正确配置它。 (在网络上我只需要复制粘贴一个
我的购物车模型如下 class Cart { String description; double unitCost; double amount; int quantity; S
在 Flutter 应用程序中,我想为在线托管的资源(图像、视频等)实现缓存。 我希望它能在原生平台 (Android/iOS)(例如使用文件系统)和网络(例如使用 IndexedDB)上运行。 Fl
我写了一个页面,在顶部一切都很好,应该是这样。在底部我有一个事件的历史。我的容器的宽度是自动确定的(取决于屏幕的宽度),而高度 - 不,在不同的设备上有不同的高度(底部的缩进是不同的)。是否可以自动确
我正在处理一个页面,其中有一些字段,例如 textfield 和 slider。在页面的末尾必须有一个用于进行下一步的按钮,该按钮被包裹在 Align 中以在页面之间具有固定位置。 另一方面,resi
我是一名优秀的程序员,十分优秀!