Flutter:ListView inside Column inside Column

Posted

技术标签:

【中文标题】Flutter:ListView inside Column inside Column【英文标题】:Flutter: ListView inside Column inside Column 【发布时间】:2020-10-03 04:25:33 【问题描述】:

你没看错标题。我在一列中有一个嵌套的小部件。小部件本身是另一列。嵌套小部件中有一个 ListView,设置为展开。出于某种原因,Flutter 不喜欢这样。我整天都在摸索如何解决这个问题。这是我的父小部件:

  @override
  Widget build(BuildContext context) 
    return StreamProvider<List<Store>>.value(
      value: DatabaseService.getStores(_cc, _zip),
      child: Column(children: [
        Container(
          decoration: BoxDecoration(
            color: Clr.primary,
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(16.0),
              bottomRight: Radius.circular(16.0),
            ),
          ),
          child: SafeArea(
            child: Column(children: [
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
                child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
                  Text(Strings.title, style: Styles.titleDark.copyWith(fontSize: 28.0)),
                  SizedBox(width: 8.0),
                  Text(_cc ?? '--', style: Styles.headerBoldDark),
                  Spacer(),
                  FlatButton(
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(24.0),
                      side: BorderSide(color: Clr.white, width: 1.5),
                    ),
                    splashColor: Colors.white30,
                    highlightColor: Colors.white10,
                    color: Colors.transparent,
                    child: Text(_zip ?? "Loading...", style: TextStyle(color: Clr.white)),
                    onPressed: () ,
                  ),
                ]),
              ),
              SizedBox(height: 8.0),
              StoresList(),
            ]),
          ),
        ),
      ]),
    );
  

这里是StoresList() 小部件。如您所见,父级是另一个 Column():

  @override
  Widget build(BuildContext context) 
    final List<Booking> bookings = Provider.of<List<Booking>>(context);
    return Column(children: [
      Container(
        decoration: BoxDecoration(
          color: Clr.primary,
          borderRadius: BorderRadius.only(bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
        ),
        child: Container(
          margin: EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 36.0),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(30.0),
            boxShadow: [BoxShadow(blurRadius: 12.0, offset: Offset(1.0, 3.0), color: Colors.black26)],
            color: Clr.white,
          ),
          child: TextField(
            decoration: AppInputDecor(
              "Search Stores, Clinics, Salons, Restaurants...",
              color: Colors.transparent,
              icon: Icons.search,
            ),
            onChanged: (search) => setState(() => _searchQuery = search),
          ),
        ),
      ),
      Consumer<List<Store>>(
        builder: (context, stores, _) 
          List<Store> storesVisible = stores?.where((s) => s.searchKey.contains(_searchQuery))?.toList();
          return Expanded(
            child: storesVisible == null
                ? Center(child: CircularProgressIndicator())
                : storesVisible.isEmpty
                    ? EmptyText("No Stores Found In The Area")
                    : ListView.builder(
                        itemCount: storesVisible.length,
                        itemBuilder: (context, idx) 
                          final Store store = storesVisible[idx];
                          return ListTile(
                            title: Text(store.name, style: Styles.header.copyWith(fontSize: 16.0)),
                            subtitle: Text(
                              store.address,
                              style: TextStyle(color: Clr.grey),
                              overflow: TextOverflow.fade,
                            ),
                            trailing: bookings.any((b) => b.storeID == store.id)
                                ? Icon(MdiIcons.bookmarkCheckOutline, color: Clr.primaryDark)
                                : null,
                          );
                        ),
          );
        ,
      ),
    ]);
  

我在尝试运行代码时收到以下错误消息。我已经尝试了调试日志告诉我的所有内容,但它仍然无法运行。此外,如果 Flutter 不只是在我的调试控制台上呕吐,那就太好了。这是一次糟糕的调试体验。

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
[38;5;244mThe following assertion was thrown during performLayout():[39;49m
RenderFlex children have non-zero flex but incoming height constraints are unbounded.

[38;5;244mWhen a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction.[39;49m
[38;5;244mThese two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.[39;49m

[38;5;248mConsider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent.[39;49m

[38;5;244mIf this message did not help you determine the problem, consider using debugDumpRenderTree():
  https://flutter.dev/debugging/#rendering-layer
  http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
[39;49m[38;5;244mThe affected RenderFlex is: RenderFlex#4fc87 relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
    [38;5;244mneeds compositing[39;49m
    [38;5;244mparentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)[39;49m
    [38;5;244mconstraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)[39;49m
    [38;5;244msize: MISSING[39;49m
    [38;5;244mdirection: vertical[39;49m
    [38;5;244mmainAxisAlignment: start[39;49m
    [38;5;244mmainAxisSize: max[39;49m
    [38;5;244mcrossAxisAlignment: center[39;49m
    [38;5;244mverticalDirection: down[39;49m
    [38;5;244mchild 1: RenderDecoratedBox#0a5d8 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
        [38;5;244mneeds compositing[39;49m
        [38;5;244mparentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)[39;49m
        [38;5;244mconstraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)[39;49m
        [38;5;244msize: Size(392.7, 87.0)[39;49m
        [38;5;244mdecoration: BoxDecoration[39;49m
            [38;5;244mcolor: Color(0xff5577ee)[39;49m
            [38;5;244mborderRadius: BorderRadius.only(bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0))[39;49m
        [38;5;244mconfiguration: ImageConfiguration(bundle: PlatformAssetBundle#37240(), devicePixelRatio: 2.8, locale: en, textDirection: TextDirection.ltr, platform: android)[39;49m
        [38;5;244mchild: RenderPadding#b5d87 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
            [38;5;244mneeds compositing[39;49m
            [38;5;244mparentData: <none> (can use size)[39;49m
            [38;5;244mconstraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)[39;49m
            [38;5;244msize: Size(392.7, 87.0)[39;49m
            [38;5;244mpadding: EdgeInsets(16.0, 0.0, 16.0, 36.0)[39;49m
            [38;5;244mtextDirection: ltr[39;49m
            [38;5;244mchild: RenderDecoratedBox#729b9 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                [38;5;244mneeds compositing[39;49m
                [38;5;244mparentData: offset=Offset(16.0, 0.0) (can use size)[39;49m
                [38;5;244mconstraints: BoxConstraints(0.0<=w<=360.7, 0.0<=h<=Infinity)[39;49m
                [38;5;244msize: Size(360.7, 51.0)[39;49m
                [38;5;244mdecoration: BoxDecoration[39;49m
                    [38;5;244mcolor: Color(0xffffffff)[39;49m
                    [38;5;244mborderRadius: BorderRadius.circular(30.0)[39;49m
                    [38;5;244mboxShadow: BoxShadow(Color(0x42000000), Offset(1.0, 3.0), 12.0, 0.0)[39;49m
                [38;5;244mconfiguration: ImageConfiguration(bundle: PlatformAssetBundle#37240(), devicePixelRatio: 2.8, locale: en, textDirection: TextDirection.ltr, platform: android)[39;49m
                [38;5;244mchild: RenderIgnorePointer#adebb relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                    [38;5;244mneeds compositing[39;49m
                    [38;5;244mparentData: <none> (can use size)[39;49m
                    [38;5;244mconstraints: BoxConstraints(0.0<=w<=360.7, 0.0<=h<=Infinity)[39;49m
                    [38;5;244msize: Size(360.7, 51.0)[39;49m
                    [38;5;244mignoring: false[39;49m
                    [38;5;244mignoringSemantics: implicitly false[39;49m
    [38;5;244mchild 2: RenderRepaintBoundary#ee9bd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
        [38;5;244mneeds compositing[39;49m
        [38;5;244mparentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight[39;49m
        [38;5;244mconstraints: MISSING[39;49m
        [38;5;244msize: MISSING[39;49m
        [38;5;244musefulness ratio: no metrics collected yet (never painted)[39;49m
        [38;5;244mchild: RenderCustomPaint#04820 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
            [38;5;244mneeds compositing[39;49m
            [38;5;244mparentData: <none>[39;49m
            [38;5;244mconstraints: MISSING[39;49m
            [38;5;244msize: MISSING[39;49m
            [38;5;244mchild: RenderRepaintBoundary#a1883 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                [38;5;244mneeds compositing[39;49m
                [38;5;244mparentData: <none>[39;49m
                [38;5;244mconstraints: MISSING[39;49m
                [38;5;244msize: MISSING[39;49m
                [38;5;244musefulness ratio: no metrics collected yet (never painted)[39;49m
                [38;5;244mchild: _RenderScrollSemantics#b4490 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                    [38;5;244mneeds compositing[39;49m
                    [38;5;244mparentData: <none>[39;49m
                    [38;5;244mconstraints: MISSING[39;49m
                    [38;5;244msemantic boundary[39;49m
                    [38;5;244msize: MISSING[39;49m
[38;5;244mThe creator information is set to: Column ← StoresList ← Column ← MediaQuery ← Padding ← SafeArea ← DecoratedBox ← Container ← Column ← _DefaultInheritedProviderScope<List<Store>> ← StreamProvider<List<Store>> ← HomeTab ← ⋯[39;49m
[38;5;244mThe nearest ancestor providing an unbounded width constraint is: RenderFlex#70bee relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m

[38;5;248mSee also: https://flutter.dev/layout/[39;49m

[38;5;244mIf none of the above helps enough to fix this problem, please don't hesitate to file a bug:
  https://github.com/flutter/flutter/issues/new?template=BUG.md
[39;49m[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;244mWhen the exception was thrown, this was the stack[39;49m
[38;5;244m#0      RenderFlex.performLayout.<anonymous closure>[39;49m
[38;5;244m#1      RenderFlex.performLayout[39;49m
[38;5;244m#2      RenderObject.layout[39;49m
[38;5;244m#3      RenderFlex.performLayout[39;49m
[38;5;244m#4      RenderObject.layout[39;49m
[38;5;244m...[39;49m
[38;5;244mThe following RenderObject was being processed when the exception was fired: RenderFlex#4fc87 relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mRenderObject: RenderFlex#4fc87 relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
    [38;5;244mneeds compositing[39;49m
    [38;5;244mparentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)[39;49m
    [38;5;244mconstraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)[39;49m
    [38;5;244msize: MISSING[39;49m
    [38;5;244mdirection: vertical[39;49m
    [38;5;244mmainAxisAlignment: start[39;49m
    [38;5;244mmainAxisSize: max[39;49m
    [38;5;244mcrossAxisAlignment: center[39;49m
    [38;5;244mverticalDirection: down[39;49m
    [38;5;244mchild 1: RenderDecoratedBox#0a5d8 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
        [38;5;244mneeds compositing[39;49m
        [38;5;244mparentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)[39;49m
        [38;5;244mconstraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)[39;49m
        [38;5;244msize: Size(392.7, 87.0)[39;49m
        [38;5;244mdecoration: BoxDecoration[39;49m
            [38;5;244mcolor: Color(0xff5577ee)[39;49m
            [38;5;244mborderRadius: BorderRadius.only(bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0))[39;49m
        [38;5;244mconfiguration: ImageConfiguration(bundle: PlatformAssetBundle#37240(), devicePixelRatio: 2.8, locale: en, textDirection: TextDirection.ltr, platform: android)[39;49m
        [38;5;244mchild: RenderPadding#b5d87 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
            [38;5;244mneeds compositing[39;49m
            [38;5;244mparentData: <none> (can use size)[39;49m
            [38;5;244mconstraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)[39;49m
            [38;5;244msize: Size(392.7, 87.0)[39;49m
            [38;5;244mpadding: EdgeInsets(16.0, 0.0, 16.0, 36.0)[39;49m
            [38;5;244mtextDirection: ltr[39;49m
            [38;5;244mchild: RenderDecoratedBox#729b9 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                [38;5;244mneeds compositing[39;49m
                [38;5;244mparentData: offset=Offset(16.0, 0.0) (can use size)[39;49m
                [38;5;244mconstraints: BoxConstraints(0.0<=w<=360.7, 0.0<=h<=Infinity)[39;49m
                [38;5;244msize: Size(360.7, 51.0)[39;49m
                [38;5;244mdecoration: BoxDecoration[39;49m
                    [38;5;244mcolor: Color(0xffffffff)[39;49m
                    [38;5;244mborderRadius: BorderRadius.circular(30.0)[39;49m
                    [38;5;244mboxShadow: BoxShadow(Color(0x42000000), Offset(1.0, 3.0), 12.0, 0.0)[39;49m
                [38;5;244mconfiguration: ImageConfiguration(bundle: PlatformAssetBundle#37240(), devicePixelRatio: 2.8, locale: en, textDirection: TextDirection.ltr, platform: android)[39;49m
                [38;5;244mchild: RenderIgnorePointer#adebb relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                    [38;5;244mneeds compositing[39;49m
                    [38;5;244mparentData: <none> (can use size)[39;49m
                    [38;5;244mconstraints: BoxConstraints(0.0<=w<=360.7, 0.0<=h<=Infinity)[39;49m
                    [38;5;244msize: Size(360.7, 51.0)[39;49m
                    [38;5;244mignoring: false[39;49m
                    [38;5;244mignoringSemantics: implicitly false[39;49m
    [38;5;244mchild 2: RenderRepaintBoundary#ee9bd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
        [38;5;244mneeds compositing[39;49m
        [38;5;244mparentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight[39;49m
        [38;5;244mconstraints: MISSING[39;49m
        [38;5;244msize: MISSING[39;49m
        [38;5;244musefulness ratio: no metrics collected yet (never painted)[39;49m
        [38;5;244mchild: RenderCustomPaint#04820 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
            [38;5;244mneeds compositing[39;49m
            [38;5;244mparentData: <none>[39;49m
            [38;5;244mconstraints: MISSING[39;49m
            [38;5;244msize: MISSING[39;49m
            [38;5;244mchild: RenderRepaintBoundary#a1883 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                [38;5;244mneeds compositing[39;49m
                [38;5;244mparentData: <none>[39;49m
                [38;5;244mconstraints: MISSING[39;49m
                [38;5;244msize: MISSING[39;49m
                [38;5;244musefulness ratio: no metrics collected yet (never painted)[39;49m
                [38;5;244mchild: _RenderScrollSemantics#b4490 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
                    [38;5;244mneeds compositing[39;49m
                    [38;5;244mparentData: <none>[39;49m
                    [38;5;244mconstraints: MISSING[39;49m
                    [38;5;244msemantic boundary[39;49m
                    [38;5;244msize: MISSING[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#4fc87 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#ef156 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mSafeArea[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
I/erflow.shopsaf(27968): Background concurrent copying GC freed 46405(1559KB) AllocSpace objects, 11(500KB) LOS objects, 49% free, 2806KB/5612KB, paused 2.549ms total 186.541ms

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderPadding#55a54 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mContainer[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderDecoratedBox#1e3cf relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#70bee relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mScaffold[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
The method '>' was called on null.
Receiver: null
Tried calling: >(1e-10)
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
Reloaded 0 of 581 libraries in 648ms.

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#4fc87 relayoutBoundary=up5 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#ef156 relayoutBoundary=up4 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mSafeArea[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderPadding#55a54 relayoutBoundary=up3 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mContainer[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderDecoratedBox#1e3cf relayoutBoundary=up2 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#70bee relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mScaffold[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
The method '>' was called on null.
Receiver: null
Tried calling: >(1e-10)
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#4fc87 relayoutBoundary=up5 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#ef156 relayoutBoundary=up4 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mSafeArea[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderPadding#55a54 relayoutBoundary=up3 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mContainer[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderDecoratedBox#1e3cf relayoutBoundary=up2 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#70bee relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mScaffold[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
The method '>' was called on null.
Receiver: null
Tried calling: >(1e-10)
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

【问题讨论】:

【参考方案1】:

解决方案是用Expanded() 包裹您的ListView.builder(),并在您的构建器中使用shrinkWrap: true。代码如下:

ListView.builder(      
  shrinkWrap: true,
  itemCount: storesVisible.length,
  itemBuilder: (context, idx) 
    final Store store = storesVisible[idx];
  ,
);

【讨论】:

嗨。删除Expanded() 并放置shrinkWrap: true 解决了我的问题。如果您可以编辑您的答案以包含它,我可以将其标记为正确!谢谢! @Adifyr 确定兄弟谢谢:D

以上是关于Flutter:ListView inside Column inside Column的主要内容,如果未能解决你的问题,请参考以下文章

带有嵌套 TabBarView 的 Flutter ListView

Flutter ListView 滚动索引滚动不足

如何在 Flutter listview streambuilder 中停止自动滚动?

Flutter Listview语言选择需要在选择时进行圆形复选框设计

Flutter:ListView内的ListView不滚动

Flutter - 另一个 Listview 中的 Listview.builder