【发布时间】:2021-03-31 11:55:55
【问题描述】:
Widget build(BuildContext context) {
super.build(context);
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
),
child: Scaffold(
key: _scaffoldKeyProfilePage,
backgroundColor: Colors.white,
body: user == null
? Center(
child: CircularProgressIndicator(),
)
: RefreshIndicator(
onRefresh: _onRefresh,
child: ListView(
shrinkWrap: true,
padding: EdgeInsets.all(0),
children: [
BuildMainProfile(
....//build profile (with heiht = ScreenHeight/1.4)
),
Container(
...//to build bio section
),
Flexible(
child: PageView(
children: [
ListView.builder(
shrinkWrap: true,
itemCount: 30,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(color: index%2==0?Colors.red:Colors.green,height: 30.0,width: double.infinity,),
);
},
),
Container(height: 400,width: 200,color: Colors.green,),
Container(height: 400,width: 200,color: Colors.blue,),
Container(height: 400,width: 200,color: Colors.pink,)
],
),
)
],
),
),
),
);
我收到一条错误消息:
ParentDataWidget Flexible(flex: 1) 想要应用 ParentData 的 将 FlexParentData 类型输入到 I/flutter (9926):RenderObject,它具有 已设置为接受不兼容类型 ParentData 的 ParentData。 I/flutter (9926):通常,这意味着灵活的小部件具有 错误的祖先 RenderObjectWidget。通常,I/flutter (9926): 灵活的小部件直接放置在 Flex 小部件中。我/颤振( 9926): 有问题的 Flexible 当前放置在 重绘边界小部件。
.
.
.
.
另一个例外是 抛出:水平视口被赋予了无限的高度。我/颤振( 9926):引发了另一个异常:未布置 RenderBox: RenderViewport#4dd2b 需要-布局需要-油漆 NEEDS-COMPOSITING-BITS-UPDATE I/flutter (9926):另一个例外是 抛出:RenderBox 未布置:RenderViewport#4dd2b NEEDS-PAINT 需要-合成-位-更新
如何消除这个错误,我什至在 PageView 上使用了 Flexible 并在 listView 中使用了 shrinkWrap。
【问题讨论】: