2
votes

The code below works without using Row widget but it gives an error on using a nested list View with Row how can I use a Row if that's my Use Case in the above code I have one row inside which there are two columns

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,
                ),
              ],
            ),
          ],
        )
      ],
    ),
  ),
);

  } }

The code gives the following error?

I/flutter ( 6704): RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14 NEEDS-LAYOUT NEEDS-PAINT I/flutter ( 6704): creator: ShrinkWrappingViewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#aa619] ← Semantics ← I/flutter ( 6704): Listener ← _GestureSemantics ← I/flutter ( 6704): RawGestureDetector-[LabeledGlobalKey#dbe17] ← I/flutter ( 6704): _ScrollSemantics-[GlobalKey#17359] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← I/flutter ( 6704): NotificationListener ← ⋯ I/flutter ( 6704): parentData: (can use size) I/flutter ( 6704): constraints: BoxConstraints(unconstrained) I/flutter ( 6704): size: MISSING I/flutter ( 6704): axisDirection: down I/flutter ( 6704): crossAxisDirection: right I/flutter ( 6704): offset: ScrollPositionWithSingleContext#d8d3b(offset: 0.0, range: null..null, viewport: null, I/flutter ( 6704): ScrollableState, ClampingScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#ce116, I/flutter ( 6704): ScrollDirection.idle) I/flutter ( 6704): This RenderObject had the following descendants (showing up to depth 5): I/flutter ( 6704): RenderSliverPadding#a684d NEEDS-LAYOUT NEEDS-PAINT I/flutter ( 6704): RenderSliverList#59143 NEEDS-LAYOUT NEEDS-PAINT I/flutter ( 6704): ════════════════════════════════════════════════════════════════════════════════════════════════════ I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#0105f relayoutBoundary=up13 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#cdf64 relayoutBoundary=up12 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#8301a relayoutBoundary=up11 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#89bf4 relayoutBoundary=up10 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#6bd35 relayoutBoundary=up9 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#417b1 relayoutBoundary=up8 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#97f18 relayoutBoundary=up7 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#df728 relayoutBoundary=up6 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderFlex#44487 relayoutBoundary=up5 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderFlex#99d5f relayoutBoundary=up4 NEEDS-PAINT I/flutter ( 6704): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 443 pos 12: 'child.hasSize': is not true. I/flutter ( 6704): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null. I/flutter ( 6704): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null. I/flutter ( 6704): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.

2
please add any picture for what you are exactly looking for?Viren V Varasadiya

2 Answers

2
votes

Wrap your Columns with Flexible Widget.

Flexible(
           child: Column(
           children: <Widget>[
1
votes

Keep in mind, whenever you are working with either Row widget or Column widget, you have to give definite sizes (less than the total available space) to all other widgets, but if you are not sure about the sizes, then give definite sizes to all the widgets, which needs minimum size to look fine, and for the other widgets use Expanded widget.

Look at this code for idea

Row(
  children: <Widget>[
    Expanded(
      //Widget that is long and can cause overflow
      child: LongWidget(),
    ),
    //Give definite Size to this widget
    FixedSizedWidget()
  ],
),