- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
当我创建一个下拉按钮小部件时,我收到了这个错误,说 RenderFlex 在右侧被无限像素溢出。源代码为:
import 'package:flutter/material.dart';
class test extends StatefulWidget {
@override
_testState createState() => _testState();
}
class _testState extends State<test> {
//gender
List<DropdownMenuItem<int>> genderList = [];
void genderLoad(){
genderList.add(new DropdownMenuItem(child: new Text("Male"),value: 1,));
genderList.add(new DropdownMenuItem(child: new Text("Female"),value: 2,));
}
//end of gender
@override
Widget build(BuildContext context) {
genderLoad();
return Scaffold(
body: new Container(
child: new Center(
child: new DropdownButton(items: genderList, onChanged: null),
),
),
);
}
}
在我构建程序后,我没有在应用程序上看到任何 DropDownButton,而是在控制台上收到错误消息。以下是错误信息:
正在执行热重启...将文件同步到为 x86 构建的设备 Android SDK...在 5,558 毫秒内重新启动应用程序。
I/flutter (15333): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (15333): The following assertion was thrown during performLayout():
I/flutter (15333): RenderIndexedStack object was given an infinite size during layout.
I/flutter (15333): This probably means that it is a render object that tries to be as big as possible, but it was put
I/flutter (15333): inside another render object that allows its children to pick their own size.
I/flutter (15333): The nearest ancestor providing an unbounded width constraint is:
I/flutter (15333): RenderFlex#9b57d relayoutBoundary=up7 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (15333): creator: Row ← Padding ← Container ← DefaultTextStyle ← Stack ← Listener ← _GestureSemantics ←
I/flutter (15333): RawGestureDetector ← GestureDetector ← Semantics ← DropdownButton<int> ← Center ← ⋯
I/flutter (15333): parentData: offset=Offset(0.0, 0.0) (can use size)
I/flutter (15333): constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=683.4)
I/flutter (15333): size: MISSING
I/flutter (15333): direction: horizontal
I/flutter (15333): mainAxisAlignment: spaceBetween
I/flutter (15333): mainAxisSize: min
I/flutter (15333): crossAxisAlignment: center
I/flutter (15333): textDirection: ltr
I/flutter (15333): verticalDirection: down
I/flutter (15333): The constraints that applied to the RenderIndexedStack were:
I/flutter (15333): BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=683.4)
I/flutter (15333): The exact size it was given was:
I/flutter (15333): Size(Infinity, 683.4)
I/flutter (15333): See https://flutter.io/layout/ for more information.
I/flutter (15333):
I/flutter (15333): When the exception was thrown, this was the stack:
I/flutter (15333): #0 RenderBox.debugAssertDoesMeetConstraints.<anonymous closure> (package:flutter/src/rendering/box.dart:1749:9)
I/flutter (15333): #1 RenderBox.debugAssertDoesMeetConstraints (package:flutter/src/rendering/box.dart:1823:6)
I/flutter (15333): #2 RenderBox.size=.<anonymous closure> (package:flutter/src/rendering/box.dart:1543:17)
I/flutter (15333): #3 RenderBox.size= (package:flutter/src/rendering/box.dart:1543:65)
I/flutter (15333): #4 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:480:7)
I/flutter (15333): #5 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #6 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
I/flutter (15333): #7 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #8 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:199:11)
I/flutter (15333): #9 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #10 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (15333): #11 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #12 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #13 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #14 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #15 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #16 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #17 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #18 RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:385:13)
I/flutter (15333): #19 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #20 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (15333): #21 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (15333): #22 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (15333): #23 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (15333): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #28 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1188:11)
I/flutter (15333): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #33 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #34 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #35 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #36 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #38 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #40 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #45 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
I/flutter (15333): #46 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #47 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (15333): #48 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #49 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #50 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #51 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #52 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #53 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #54 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #55 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #56 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #57 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #58 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #59 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (15333): #60 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (15333): #61 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
I/flutter (15333): #62 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (15333): #63 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (15333): #64 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (15333): #65 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (15333): #66 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (15333): #67 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (15333): #68 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (15333): #69 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter (15333): #71 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (15333): #72 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (15333): #73 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (15333): (elided one frame from package dart:async)
I/flutter (15333):
I/flutter (15333): The following RenderObject was being processed when the exception was fired:
I/flutter (15333): RenderIndexedStack#d77d9 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (15333): creator: IndexedStack ← Row ← Padding ← Container ← DefaultTextStyle ← Stack ← Listener ←
I/flutter (15333): _GestureSemantics ← RawGestureDetector ← GestureDetector ← Semantics ← DropdownButton<int> ← ⋯
I/flutter (15333): parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
I/flutter (15333): constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=683.4)
I/flutter (15333): size: Size(Infinity, 683.4)
I/flutter (15333): alignment: AlignmentDirectional.centerStart
I/flutter (15333): textDirection: ltr
I/flutter (15333): fit: loose
I/flutter (15333): overflow: clip
I/flutter (15333): index: null
I/flutter (15333): This RenderObject has no descendants.
I/flutter (15333): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (15333): Another exception was thrown: A RenderFlex overflowed by Infinity pixels on the right.
最佳答案
设置 isExpanded: true
.并给它的 Container 一个合适的 height
(例如 48),或者设置 isDense: true
或 do not pass a null onChanged
event or a null list of items ,但是如果您出于任何原因想要禁用小部件(用户不必单击它),我想设置前一个条件可以满足您的所有需求。
class _testState extends State<test> {
//gender
List<DropdownMenuItem<int>> genderList = [];
void genderLoad() {
genderList.clear();
genderList.add(new DropdownMenuItem(
child: new Text("Male"),
value: 1,
));
genderList.add(new DropdownMenuItem(
child: new Text("Female"),
value: 2,
));
}
//end of gender
@override
Widget build(BuildContext context) {
genderLoad();
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text('hello'),
),
body: Container(
height: 48,
color: Colors.lightGreenAccent,
child: DropdownButton(
isDense: false,
isExpanded: true,
items: genderList,
onChanged: (selected){
print(selected);
})));
}
}
有这个打开issue当您在必填字段上传递空值时,这会使 DropDownButton
小部件不呈现。
所以所有这些:
DropdownButton(items: [], onChanged: (int) {})
DropdownButton(items: genderList, onChanged: null)
DropdownButton(items: [], onChanged: null)
有问题。解决方法是这篇文章中显示的解决方法。
return Scaffold(
body: new Container(
width: 48,
child: new Center(
child: new DropdownButton (
isExpanded: true,
items: [],
onChanged: null
),
),
),
);
关于android - 使用 DropdownButton 小部件时右侧无限像素溢出的 RenderFlex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53955763/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!