flutter - Flutter CupertinoPicker 不渲染
问题描述
试图让 Flutter CupertinoPicker 在 Flutter 1.7 上工作。没有花哨的东西,只是脚手架体内的基本代码......
只使用强制元素......甚至尝试了其他人的示例代码,没有任何效果。
CupertinoPicker(
itemExtent: 30.0,
onSelectedItemChanged: (int idx) {
setState(() {
_prayer.rebuild((b) =>
b..category = listOfStrings[idx]);
});
},
children: List<Widget>.generate(
listOfStrings.length,
(int i) {
return Text('Dummy Text');
},
),
)
flutter: Another exception was thrown: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#fdf27 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#052f5 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#0d6c9 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#fdf27 relayoutBoundary=up3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#052f5 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#0d6c9 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: NoSuchMethodError: The method '>' was called on null.
Android Picker 工作......是否需要父 Widget 应该基于 Cupertino 或其他东西?
解决方案
Expanded(
child:
CupertinoPicker(
backgroundColor: Colors.white,
onSelectedItemChanged: (index) {
},
itemExtent: 50.0,
children:new List<Widget>.generate(
companyList.length, (int index) {
return new Center(
child: new Text(
"${companyList[index]}",
style: TextStyle(fontSize: 16,fontFamily:
'HelveticaRegular'),),
);})
))
推荐阅读
- vue.js - 关于ace编辑器,如何监控用户输入的字符
- c# - 创建列表并乘以
- python - 我的自定义函数返回错误的东西,而不是 Python 中的编译字符串
- ios - 重新加载集合视图后如何解决 UIButton 边框问题
- c# - ASP.NET MVC Git Pull 对我不起作用
- c# - 如何通过组合每个列表中的一个元素将两个不同对象的列表组合成一个列表?
- python - 凯撒密码问题
- php - 数组中的日期时间,然后从现在减去
- python - 在密码管理器中使用 if 语句会给我一个 Python 中的 NameError
- java - 从二维数组中随机的最大和最小数中查找二维数组索引