下面的代码不使用行小部件,但在使用嵌套列表视图和行时会出现错误,如果这是我的用例,那么在上面的代码中,我有一行,其中有两列
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text("Dashboard"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.add_circle),
iconSize: 50.0,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => AddMember(),
),
);
},
),
],
),
drawer: MainDrawer(),
body: Container(
decoration: BoxDecoration(
image: Background().buildBackgroundImage(),
),
child: ListView(
children: <Widget>[
Row(
children: <Widget>[
Column(
children: <Widget>[
Text("1"),
],
),
Column(
children: <Widget>[
Text("Hammad"),
ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return Text("data");
},
itemCount: 100,
),
],
),
],
)
],
),
),
);
} }代码会产生以下错误?
I/颤振( 6704):RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14需要-布局需要-油漆I/颤振( 6704):创建者: ShrinkWrappingViewport←_ScrollableScope←IgnorePointer#a 619←Semantic←I/flutter ( 6704):听者←_GestureSemantics←I/颤振( 6704):RawGestureDetector-LabeledGlobalKey#dbe17←I/flutter ( 6704):_ScrollSemantics-GlobalKey#17359 _GestureSemantics RepaintBoundary CustomPaint RepaintBoundary parentData( 6704):NotificationListener I/flutter ( 6704):(可使用大小)I/颤振( 6704):约束:BoxConstraints(无约束)I/颤振( 6704):尺寸:缺失I/颤振( 6704):axisDirection:下行I/颤振( 6704):crossAxisDirection:右I/颤振( 6704):偏移:ScrollPositionWithSingleContext#d8d3b(偏移:0,范围: null..null,视口: null,I/颤振( 6704):ScrollableState,ClampingScrollPhysics -> ClampingScrollPhysics,IdleScrollActivity#ce116,I/颤振( 6704):ScrollDirection.idle) I/颤振( 6704):这个RenderObject有以下后代(显示深度5):I/颤振( 6704):RenderSliverPadding#a684d需要-布局需要-油漆I/颤振( 6704):RenderSliverList#59143需要-布局需要-油漆I/颤振( 6704):════════════════════════════════════════════════════════════════════════════════════════════════════I/颤振( 6704):另一个异常被抛出: RenderBox未被布局: RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14 RenderBox RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14 RenderBox/颤振( 6704):另一个异常被抛出:RenderBox未布局: RenderIgnorePointer#0105f relayoutBoundary=up13 RenderBox油漆I/颤振( 6704):抛出了另一个异常: RenderBox未被部署: RenderSemanticsAnnotations#cdf64 relayoutBoundary=up12 RenderBox油漆I/颤振( 6704):另一个异常被抛出: RenderBox未布局: RenderPointerListener#8301a relayoutBoundary=up11 RenderBox laid /颤振( 6704):另一个异常被抛出: RenderBox未布局: RenderSemanticsGestureHandler#89bf4 relayoutBoundary=up10 RenderBox油漆I/颤振(6704);抛出了另一个异常:RenderBox未布局:_RenderScrollSemantics#6bd35 relayoutBoundary=up9需要--油漆I/颤振( 6704):抛出了另一个异常:RenderBox未布局: RenderRepaintBoundary#417b1 relayoutBoundary=up8需要-油漆I/颤振( 6704):另一个异常被抛出: RenderBox未被布局: RenderCustomPaint#97f18 relayoutBoundary=up7 RenderBox was /颤振( 6704):另一个异常被抛出: RenderBox未被布局: RenderRepaintBoundary#df728 relayoutBoundary=up6需求-油漆I/颤振( 6704):另一个异常被抛出: RenderBox未被部署: RenderFlex#44487 relayoutBoundary=up5需要-油漆I/颤振( 6704):另一个异常被抛出:RenderBox未被部署: RenderFlex#99d5f relayoutBoundary=up4需要-油漆I/颤振( 6704):另一个例外被抛出:引发:'package:flutter/src/rendering/sliver_multi_box_adaptor.dart':失败断言:第443行pos 12:‘Failed .assertion’:不是真。I/颤振( 6704):引发另一个异常: NoSuchMethodError:在null上调用getter 'scrollOffsetCorrection‘。I/debugAssertIsValid( 6704):抛出另一个异常:debugAssertIsValid:方法'debugAssertIsValid‘被调用为null。I/颤振( 6704):引发了另一个异常: NoSuchMethodError:在null上调用了getter 'visible‘。
发布于 2018-11-05 05:44:04
用灵活的Widget包装您的列。
Flexible(
child: Column(
children: <Widget>[发布于 2020-04-23 12:16:28
请记住,每当您使用Row小部件或列小部件时,都必须为所有其他小部件指定一定的大小(小于可用空间),但是如果您不确定大小,那么就给所有小部件指定大小,这需要最小的大小才能看上去很好,对于其他小部件使用扩展小部件。
查看idea的代码
Row(
children: <Widget>[
Expanded(
//Widget that is long and can cause overflow
child: LongWidget(),
),
//Give definite Size to this widget
FixedSizedWidget()
],
), https://stackoverflow.com/questions/53148038
复制相似问题