ListView中的Flutter_swiper无法正常工作,它会使应用程序崩溃

问题描述 投票:1回答:1

我当前面临一个问题,我有一个listview,其中填充了来自服务器的数据,我希望使用flutter swiper来浏览数据中给定项目集中的图像,因此我实现了flutter_swiper,但我不断错误,当我卸下flutter_swiper时,其他所有东西都工作正常。

请注意,我已删除了这段代码中不重要的部分

这里是我的代码]

return ListView.builder(
    itemCount: _itemCount,
    itemBuilder: ( context, index ) =>
        Column(
          children: <Widget>[
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                Padding(
                  //user avatar
                  padding: const EdgeInsets.all(8.0),
                  child: Container(
                    width: 40.0,
                    height: 40.0,
                    decoration: new BoxDecoration(
                      shape: BoxShape.circle,
                      image: DecorationImage(
                        fit: BoxFit.fitHeight,
                        image: NetworkImage(
                            profileimages[index],

                        ),
                      ),
                    ),
                  ),
                ),
                        //images
                        ClipRRect(
                            borderRadius:
                            BorderRadius.circular(8.0),
                            child: images[index].isEmpty
                                ? null
                                : Row(
                                  children: <Widget>[
                                    SafeArea(
                                      top: true,
                                      bottom: true,
                                      child: Swiper(

                                        itemCount: images[index].length,
                                        pagination: new 
SwiperPagination(),
                                        itemBuilder: (context,int index2){
                                          return images[index][index2];
                                        },
                                      ),
                                    ),
                                  ],
                                )
                ),
          ],
        ),
  );

下面是错误日志

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.

When 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.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.

Consider 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.

If 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
The affected RenderFlex is: RenderFlex#7693b relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  parentData: offset=Offset(0.0, 0.0) (can use size)
  constraints: BoxConstraints(w=288.0, 0.0<=h<=Infinity)
  size: MISSING
  direction: vertical
  mainAxisAlignment: start
  mainAxisSize: max
  crossAxisAlignment: start
  textDirection: ltr
  verticalDirection: down
...  child 1: RenderFlex#ed364 relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...    constraints: BoxConstraints(0.0<=w<=288.0, 0.0<=h<=Infinity)
...    size: Size(288.0, 48.0)
...    direction: horizontal
...    mainAxisAlignment: spaceBetween
...    mainAxisSize: max
...    crossAxisAlignment: center
...    textDirection: ltr
...    verticalDirection: down
...    child 1: RenderWrap#77233 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 12.0); flex=null; fit=null (can use size)
...      constraints: BoxConstraints(unconstrained)
...      size: Size(132.0, 24.0)
...      direction: horizontal
...      alignment: start
...      spacing: 0.0
...      runAlignment: start
...      runSpacing: 0.0
...      crossAxisAlignment: 0.0
...      textDirection: ltr
...      child 1: RenderParagraph#78913 relayoutBoundary=up11 NEEDS-PAINT
...        parentData: offset=Offset(0.0, 0.0) (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: Size(50.0, 24.0)
...        textAlign: start
...        textDirection: ltr
...        softWrap: wrapping at box width
...        overflow: clip
...        locale: en_US
...        maxLines: unlimited
...        text: TextSpan
...          debugLabel: ((englishLike body1 2014).merge(((blackMountainView body1).apply).merge(unknown))).merge(unknown)
...          inherit: false
...          color: Color(0xff000000)
...          family: Product Sans
...          size: 20.0
...          weight: 700
...          baseline: alphabetic
...          decoration: TextDecoration.none
...          "fas df"
...      child 2: RenderPadding#6b190 relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(50.0, 0.0) (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: Size(82.0, 24.0)
...        padding: EdgeInsets(8.0, 0.0, 0.0, 0.0)
...        textDirection: ltr
...        child: RenderParagraph#1b44b relayoutBoundary=up12 NEEDS-PAINT
...          parentData: offset=Offset(8.0, 0.0) (can use size)
...          constraints: BoxConstraints(unconstrained)
...          size: Size(74.0, 24.0)
...          textAlign: start
...          textDirection: ltr
...          softWrap: wrapping at box width
...          overflow: clip
...          locale: en_US
...          maxLines: unlimited
...    child 2: RenderSemanticsAnnotations#34240 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(240.0, 0.0); flex=null; fit=null (can use size)
...      constraints: BoxConstraints(unconstrained)
...      size: Size(48.0, 48.0)
...      child: RenderSemanticsAnnotations#f2398 relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: Size(48.0, 48.0)
...        child: RenderMouseRegion#f58e3 relayoutBoundary=up12 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(unconstrained)
...          size: Size(48.0, 48.0)
...          listeners: enter, exit
...  child 2: RenderPadding#2cd3e relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...    constraints: BoxConstraints(0.0<=w<=288.0, 0.0<=h<=Infinity)
...    size: Size(288.0, 8.0)
...    padding: EdgeInsets(0.0, 0.0, 0.0, 8.0)
...    textDirection: ltr
...    child: RenderLimitedBox#4a487 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0) (can use size)
...      constraints: BoxConstraints(0.0<=w<=288.0, 0.0<=h<=Infinity)
...      size: Size(288.0, 0.0)
...      maxWidth: 0.0
...      maxHeight: 0.0
...      child: RenderConstrainedBox#1fcbc relayoutBoundary=up11 NEEDS-PAINT
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(0.0<=w<=288.0, h=0.0)
...        size: Size(288.0, 0.0)
...        additionalConstraints: BoxConstraints(biggest)
...  child 3: RenderClipRRect#97678 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
...    constraints: MISSING
...    size: MISSING
...    child: RenderFlex#13255 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: <none>
...      constraints: MISSING
...      size: MISSING
...      direction: horizontal
...      mainAxisAlignment: start
...      mainAxisSize: max
...      crossAxisAlignment: center
...      textDirection: ltr
...      verticalDirection: down
...      child 1: RenderPadding#a2c8f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        padding: EdgeInsets.zero
...        textDirection: ltr
...        child: RenderStack#365af NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0)
...          constraints: MISSING
...          size: MISSING
...          alignment: AlignmentDirectional.topStart
...          textDirection: ltr
...          fit: loose
...          overflow: clip
...  child 4: RenderPadding#a51e2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...    constraints: MISSING
...    size: MISSING
...    padding: EdgeInsets(0.0, 8.0, 16.0, 13.0)
...    textDirection: ltr
...    child: RenderFlex#68acd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      direction: horizontal
...      mainAxisAlignment: spaceAround
...      mainAxisSize: max
...      crossAxisAlignment: center
...      textDirection: ltr
...      verticalDirection: down
...      child 1: RenderFlex#b16b0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        direction: horizontal
...        mainAxisAlignment: start
...        mainAxisSize: max
...        crossAxisAlignment: center
...        textDirection: ltr
...        verticalDirection: down
...        child 1: RenderConstrainedBox#6a189 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...        child 2: RenderConstrainedBox#954fe NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...      child 2: RenderFlex#8acba NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        direction: horizontal
...        mainAxisAlignment: start
...        mainAxisSize: max
...        crossAxisAlignment: center
...        textDirection: ltr
...        verticalDirection: down
...        child 1: RenderConstrainedBox#24236 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...        child 2: RenderConstrainedBox#3a880 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...      child 3: RenderFlex#356b6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        direction: horizontal
...        mainAxisAlignment: start
...        mainAxisSize: max
...        crossAxisAlignment: center
...        textDirection: ltr
...        verticalDirection: down
...        child 1: RenderConstrainedBox#5a84c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=18.0, h=10.0)
...        child 2: RenderConstrainedBox#69247 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
The creator information is set to: Column ← Padding ← Expanded ← Row ← Column ← RepaintBoundary ← IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive ← AutomaticKeepAlive ← KeyedSubtree ← SliverList ← ⋯

See also: https://flutter.dev/layout/

If 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
The relevant error-causing widget was: 
  Column file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:199:32
When the exception was thrown, this was the stack: 
#0      RenderFlex.performLayout.<anonymous closure> (package:flutter/src/rendering/flex.dart:691:11)
#1      RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:718:10)
#2      RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
#3      RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:206:11)
#4      RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
...
The following RenderObject was being processed when the exception was fired: RenderFlex#7693b relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  parentData: offset=Offset(0.0, 0.0) (can use size)
...  constraints: BoxConstraints(w=288.0, 0.0<=h<=Infinity)
...  size: MISSING
...  direction: vertical
...  mainAxisAlignment: start
...  mainAxisSize: max
...  crossAxisAlignment: start
...  textDirection: ltr
...  verticalDirection: down
RenderObject: RenderFlex#7693b relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  parentData: offset=Offset(0.0, 0.0) (can use size)
  constraints: BoxConstraints(w=288.0, 0.0<=h<=Infinity)
  size: MISSING
  direction: vertical
  mainAxisAlignment: start
  mainAxisSize: max
  crossAxisAlignment: start
  textDirection: ltr
  verticalDirection: down
...  child 1: RenderFlex#ed364 relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...    constraints: BoxConstraints(0.0<=w<=288.0, 0.0<=h<=Infinity)
...    size: Size(288.0, 48.0)
...    direction: horizontal
...    mainAxisAlignment: spaceBetween
...    mainAxisSize: max
...    crossAxisAlignment: center
...    textDirection: ltr
...    verticalDirection: down
...    child 1: RenderWrap#77233 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 12.0); flex=null; fit=null (can use size)
...      constraints: BoxConstraints(unconstrained)
...      size: Size(132.0, 24.0)
...      direction: horizontal
...      alignment: start
...      spacing: 0.0
...      runAlignment: start
...      runSpacing: 0.0
...      crossAxisAlignment: 0.0
...      textDirection: ltr
...      child 1: RenderParagraph#78913 relayoutBoundary=up11 NEEDS-PAINT
...        parentData: offset=Offset(0.0, 0.0) (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: Size(50.0, 24.0)
...        textAlign: start
...        textDirection: ltr
...        softWrap: wrapping at box width
...        overflow: clip
...        locale: en_US
...        maxLines: unlimited
...        text: TextSpan
...          debugLabel: ((englishLike body1 2014).merge(((blackMountainView body1).apply).merge(unknown))).merge(unknown)
...          inherit: false
...          color: Color(0xff000000)
...          family: Product Sans
...          size: 20.0
...          weight: 700
...          baseline: alphabetic
...          decoration: TextDecoration.none
...          "fas df"
...      child 2: RenderPadding#6b190 relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(50.0, 0.0) (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: Size(82.0, 24.0)
...        padding: EdgeInsets(8.0, 0.0, 0.0, 0.0)
...        textDirection: ltr
...        child: RenderParagraph#1b44b relayoutBoundary=up12 NEEDS-PAINT
...          parentData: offset=Offset(8.0, 0.0) (can use size)
...          constraints: BoxConstraints(unconstrained)
...          size: Size(74.0, 24.0)
...          textAlign: start
...          textDirection: ltr
...          softWrap: wrapping at box width
...          overflow: clip
...          locale: en_US
...          maxLines: unlimited
...    child 2: RenderSemanticsAnnotations#34240 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(240.0, 0.0); flex=null; fit=null (can use size)
...      constraints: BoxConstraints(unconstrained)
...      size: Size(48.0, 48.0)
...      child: RenderSemanticsAnnotations#f2398 relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: Size(48.0, 48.0)
...        child: RenderMouseRegion#f58e3 relayoutBoundary=up12 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(unconstrained)
...          size: Size(48.0, 48.0)
...          listeners: enter, exit
...  child 2: RenderPadding#2cd3e relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...    constraints: BoxConstraints(0.0<=w<=288.0, 0.0<=h<=Infinity)
...    size: Size(288.0, 8.0)
...    padding: EdgeInsets(0.0, 0.0, 0.0, 8.0)
...    textDirection: ltr
...    child: RenderLimitedBox#4a487 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0) (can use size)
...      constraints: BoxConstraints(0.0<=w<=288.0, 0.0<=h<=Infinity)
...      size: Size(288.0, 0.0)
...      maxWidth: 0.0
...      maxHeight: 0.0
...      child: RenderConstrainedBox#1fcbc relayoutBoundary=up11 NEEDS-PAINT
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(0.0<=w<=288.0, h=0.0)
...        size: Size(288.0, 0.0)
...        additionalConstraints: BoxConstraints(biggest)
...  child 3: RenderClipRRect#97678 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
...    constraints: MISSING
...    size: MISSING
...    child: RenderFlex#13255 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: <none>
...      constraints: MISSING
...      size: MISSING
...      direction: horizontal
...      mainAxisAlignment: start
...      mainAxisSize: max
...      crossAxisAlignment: center
...      textDirection: ltr
...      verticalDirection: down
...      child 1: RenderPadding#a2c8f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        padding: EdgeInsets.zero
...        textDirection: ltr
...        child: RenderStack#365af NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0)
...          constraints: MISSING
...          size: MISSING
...          alignment: AlignmentDirectional.topStart
...          textDirection: ltr
...          fit: loose
...          overflow: clip
...  child 4: RenderPadding#a51e2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...    constraints: MISSING
...    size: MISSING
...    padding: EdgeInsets(0.0, 8.0, 16.0, 13.0)
...    textDirection: ltr
...    child: RenderFlex#68acd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      direction: horizontal
...      mainAxisAlignment: spaceAround
...      mainAxisSize: max
...      crossAxisAlignment: center
...      textDirection: ltr
...      verticalDirection: down
...      child 1: RenderFlex#b16b0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        direction: horizontal
...        mainAxisAlignment: start
...        mainAxisSize: max
...        crossAxisAlignment: center
...        textDirection: ltr
...        verticalDirection: down
...        child 1: RenderConstrainedBox#6a189 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...        child 2: RenderConstrainedBox#954fe NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...      child 2: RenderFlex#8acba NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        direction: horizontal
...        mainAxisAlignment: start
...        mainAxisSize: max
...        crossAxisAlignment: center
...        textDirection: ltr
...        verticalDirection: down
...        child 1: RenderConstrainedBox#24236 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...        child 2: RenderConstrainedBox#3a880 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
...      child 3: RenderFlex#356b6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...        constraints: MISSING
...        size: MISSING
...        direction: horizontal
...        mainAxisAlignment: start
...        mainAxisSize: max
...        crossAxisAlignment: center
...        textDirection: ltr
...        verticalDirection: down
...        child 1: RenderConstrainedBox#5a84c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=18.0, h=10.0)
...        child 2: RenderConstrainedBox#69247 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...          constraints: MISSING
...          size: MISSING
...          additionalConstraints: BoxConstraints(w=20.0, h=20.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (2) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#7693b relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was: 
  Padding file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:197:30
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (3) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderPadding#b5ebc relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was: 
  Row file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:173:17
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (4) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#f4102 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was: 
  Column file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:171:13
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (5) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#f5f3c relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was: 
  ListView file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:168:23
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (6) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderRepaintBoundary#820bb relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was: 
  ListView file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:168:23
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (7) Exception caught by rendering library ═════════════════════════════════════════════════
'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 549 pos 12: 'child.hasSize': is not true.
The relevant error-causing widget was: 
  ListView file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:168:23
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (8) Exception caught by rendering library ═════════════════════════════════════════════════
The getter 'scrollOffsetCorrection' was called on null.
Receiver: null
Tried calling: scrollOffsetCorrection
The relevant error-causing widget was: 
  ListView file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:168:23
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (9) Exception caught by rendering library ═════════════════════════════════════════════════
The method 'debugAssertIsValid' was called on null.
Receiver: null
Tried calling: debugAssertIsValid()
The relevant error-causing widget was: 
  ListView file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:168:23
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ (10) Exception caught by rendering library ════════════════════════════════════════════════
The getter 'visible' was called on null.
Receiver: null
Tried calling: visible
The relevant error-causing widget was: 
  ListView file:///C:/Users/CUBICLAB/Desktop/flutterdev/fansalone/lib/screens/user/home_body.dart:168:23
════════════════════════════════════════════════════════════════════════════════════════════════════````

flutter flutter-layout flutter-test
1个回答
0
投票

问题是,Swiper小部件从“渲染”框突出,因此您需要将其放置在具有约束宽度和高度的小部件中,如SizedBox,>

这里是解决方法

SizedBox(
          height: 200,
          width: 200,
          child: Swiper(
                    itemCount: images[index].length,
                    pagination: new SwiperPagination(),
                    itemBuilder: (context,int index2){
                           return images[index][index2];
                        },
                     ),
                 ),
© www.soinside.com 2019 - 2024. All rights reserved.