下面的代码无需使用Row小部件即可工作,但是如果使用嵌套列表View with Row,则会出现错误,如果在上面的代码中这是我的用例,该如何使用Row我在其中有一行,其中有两列< / p>
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 / flutter(6704):RenderShrinkWrappingViewport#9e1c7 relayoutBoundary = up14 NEEDS-LAYOUT NEEDS-PAINT I / flutter(6704):创建者:ShrinkWrappingViewport←_ScrollableScope←IgnorePointer- [GlobalKey#aa619]←语义← I / flutter(6704):侦听器←__手势语义← I / flutter(6704):RawGestureDetector- [LabeledGlobalKey#dbe17]← I / flutter(6704):_ScrollSemantics- [GlobalKey#17359]←RepaintBoundary←CustomPaint←RepaintBoundary← I /颤振(6704):NotificationListener←⋯ I /颤振(6704):parentData:(可以使用大小) I / flutter(6704):约束:BoxConstraints(无约束) I / flutter(6704):大小:MISSING I /颤振(6704):轴方向:向下 I /颤振(6704):crossAxisDirection:右 I / flutter(6704):偏移量:ScrollPositionWithSingleContext#d8d3b(偏移量:0.0,范围:null..null,视口:null, I / flutter(6704):ScrollableState,ClampingScrollPhysics-> ClampingScrollPhysics,IdleScrollActivity#ce116, I /颤振(6704):ScrollDirection.idle) I / flutter(6704):此RenderObject具有以下子孙(显示到深度5): I / Flutter(6704):RenderSliverPadding#a684d需求布局需求油漆 I / Flutter(6704):RenderSliverList#59143需求布局需求油漆 I /颤振(6704):═══════════════════════════════════════════ ══════════════════════════════════════════════════ ═══════ I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderShrinkWrappingViewport#9e1c7 relayoutBoundary = up14 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderIgnorePointer#0105f relayoutBoundary = up13 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderSemanticsAnnotations#cdf64 relayoutBoundary = up12 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderPointerListener#8301a relayoutBoundary = up11 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderSemanticsGestureHandler#89bf4 relayoutBoundary = up10 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:_RenderScrollSemantics#6bd35 relayoutBoundary = up9 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderRepaintBoundary#417b1 relayoutBoundary = up8 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderCustomPaint#97f18 relayoutBoundary = up7 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderRepaintBoundary#df728 relayoutBoundary = up6 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderFlex#44487 relayoutBoundary = up5 NEEDS-PAINT I / flutter(6704):引发了另一个异常:未布置RenderBox:RenderFlex#99d5f relayoutBoundary = up4 NEEDS-PAINT I / flutter(6704):引发了另一个异常:'package:flutter / src / rendering / sliver_multi_box_adaptor.dart':失败的断言:443行pos 12:'child.hasSize':不正确。 I / flutter(6704):引发了另一个异常:NoSuchMethodError:在null上调用了getter'scrollOffsetCorrection'。 I / flutter(6704):引发了另一个异常:NoSuchMethodError:方法'debugAssertIsValid'在null上调用。 I / flutter(6704):引发了另一个异常:NoSuchMethodError:在null上调用了getter'visible'。
答案 0 :(得分:2)
使用“灵活小部件”包装您的列。
Flexible(
child: Column(
children: <Widget>[
答案 1 :(得分:1)
请记住,无论何时使用“行”小部件或“列”小部件,都必须为所有其他小部件提供确定的大小(小于总可用空间),但是如果不确定大小,则给出所有小部件的大小都必须确定,需要最小的大小才能看起来很好,而其他小部件则使用扩展小部件。
查看此代码以获取想法
Row(
children: <Widget>[
Expanded(
//Widget that is long and can cause overflow
child: LongWidget(),
),
//Give definite Size to this widget
FixedSizedWidget()
],
),