Flutter:我可以在数据表中一行的数据单元内使用ListviewBuilder吗?

时间:2019-09-27 10:32:06

标签: flutter flutter-layout

我想在我的应用程序中显示一个数据表。在这里,对于连续的每个项目,我要针对该项目显示多个价格。我正在使用flutter datatable小部件。我在该行的数据单元格内使用listviewbuilder来显示多个价格。但是,它不起作用。有可能这样做吗?

       DataTable(
                columns: <DataColumn>[
                      DataColumn(
                        label: Text(
                          "item",
                          style: TextStyle(
                            fontSize: 15,
                            color: Colors.red,
                          ),
                        ),
                      ),
                      DataColumn(
                        label: Text(
                          "price",
                          style: TextStyle(
                            fontSize: 15,
                            color: Colors.red,
                          ),
                        ),
                      ),
                    ],
                    rows: complaintData
                        .map(
                          (element) => DataRow(
                            cells: [
                              DataCell(
                                Text(element.item),
                              ),
                              DataCell(
                               ListView.builder(
                    physics: ClampingScrollPhysics(),
                    shrinkWrap: true,
                    itemCount: element.price.length,
                    itemBuilder: (context, i) {
                              return  Text(element.price[i].name);

                    },),
                   ),
                    ),
                            ],
                          ),
                        )
                        .toList(),
                  )

这是我面临的错误

flutter: The following assertion was thrown during performLayout():
flutter: RenderShrinkWrappingViewport does not support returning intrinsic dimensions.
flutter: Calculating the intrinsic dimensions would require instantiating every child of the viewport, which
flutter: defeats the point of viewports being lazy.
flutter: If you are merely trying to shrink-wrap the viewport in the main axis direction, you should be able
flutter: to achieve that effect by just giving the viewport loose constraints, without needing to measure its
flutter: intrinsic dimensions.
flutter:
flutter: User-created ancestor of the error-causing widget was:
flutter:   DataTable
flutter:   file:///Users/juthisarker/Documents/Source%20Code/untitled%20folder/hcmob/lib/screens/profile/complaint/ComplaintListScreen.dart:256:24
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      RenderShrinkWrappingViewport.debugThrowIfNotCheckingIntrinsics.<anonymous closure> 
flutter: #1      RenderShrinkWrappingViewport.debugThrowIfNotCheckingIntrinsics 
flutter: #2      RenderViewportBase.computeMaxIntrinsicWidth 
flutter: #3      RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #4      _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #5      RenderBox._computeIntrinsicDimension 
flutter: #6      RenderBox.getMaxIntrinsicWidth 
flutter: #7      RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #8      RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #9      _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #10     RenderBox._computeIntrinsicDimension 
flutter: #11     RenderBox.getMaxIntrinsicWidth 
flutter: #12     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #13     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #14     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #15     RenderBox._computeIntrinsicDimension 
flutter: #16     RenderBox.getMaxIntrinsicWidth 
flutter: #17     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #18     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #19     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #20     RenderBox._computeIntrinsicDimension 
flutter: #21     RenderBox.getMaxIntrinsicWidth 
flutter: #22     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #23     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #24     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #25     RenderBox._computeIntrinsicDimension 
flutter: #26     RenderBox.getMaxIntrinsicWidth 
flutter: #27     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #28     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #29     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #30     RenderBox._computeIntrinsicDimension 
flutter: #31     RenderBox.getMaxIntrinsicWidth 
flutter: #32     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #33     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #34     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #35     RenderBox._computeIntrinsicDimension 
flutter: #36     RenderBox.getMaxIntrinsicWidth 
flutter: #37     RenderShiftedBox.computeMaxIntrinsicWidth 
flutter: #38     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #39     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #40     RenderBox._computeIntrinsicDimension 
flutter: #41     RenderBox.getMaxIntrinsicWidth 
flutter: #42     RenderPadding.computeMaxIntrinsicWidth 
flutter: #43     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #44     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #45     RenderBox._computeIntrinsicDimension 
flutter: #46     RenderBox.getMaxIntrinsicWidth 
flutter: #47     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #48     RenderConstrainedBox.computeMaxIntrinsicWidth 
flutter: #49     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #50     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #51     RenderBox._computeIntrinsicDimension 
flutter: #52     RenderBox.getMaxIntrinsicWidth 
flutter: #53     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #54     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #55     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #56     RenderBox._computeIntrinsicDimension 
flutter: #57     RenderBox.getMaxIntrinsicWidth 
flutter: #58     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #59     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #60     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #61     RenderBox._computeIntrinsicDimension 
flutter: #62     RenderBox.getMaxIntrinsicWidth 
flutter: #63     RenderProxyBoxMixin.computeMaxIntrinsicWidth 
flutter: #64     RenderBox._computeIntrinsicDimension.<anonymous closure> 
flutter: #65     _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
flutter: #66     RenderBox._computeIntrinsicDimension 
flutter: #67     RenderBox.getMaxIntrinsicWidth 
flutter: #68     IntrinsicColumnWidth.maxIntrinsicWidth 
flutter: #69     RenderTable._computeColumnWidths 
flutter: #70     RenderTable.performLayout 
flutter: #71     RenderObject.layout 
flutter: #72     RenderPadding.performLayout 
flutter: #73     RenderObject.layout 
flutter: #74     RenderPadding.performLayout 
flutter: #75     RenderObject.layout 
flutter: #76     RenderFlex.performLayout 
flutter: #77     RenderObject.layout 
flutter: #78     RenderPadding.performLayout 
flutter: #79     RenderObject.layout 
flutter: #80     _RenderSingleChildViewport.performLayout 
flutter: #81     RenderObject.layout 
flutter: #82     RenderProxyBoxMixin.performLayout 
flutter: #83     RenderObject.layout 
flutter: #84     RenderProxyBoxMixin.performLayout 
flutter: #85     RenderObject.layout 
flutter: #86     RenderProxyBoxMixin.performLayout 
flutter: #87     RenderObject.layout 
flutter: #88     RenderProxyBoxMixin.performLayout 
flutter: #89     RenderObject.layout 
flutter: #90     RenderProxyBoxMixin.performLayout 
flutter: #91     RenderObject.layout 
flutter: #92     RenderProxyBoxMixin.performLayout 
flutter: #93     RenderObject.layout 
flutter: #94     MultiChildLayoutDelegate.layoutChild 
flutter: #95     _ScaffoldLayout.performLayout 
flutter: #96     MultiChildLayoutDelegate._callPerformLayout 
flutter: #97     RenderCustomMultiChildLayoutBox.performLayout 
flutter: #98     RenderObject.layout 
flutter: #99     RenderProxyBoxMixin.performLayout 
flutter: #100    RenderObject.layout 
flutter: #101    RenderProxyBoxMixin.performLayout 
flutter: #102    _RenderCustomClip.performLayout 
flutter: #103    RenderObject.layout 
flutter: #104    RenderPadding.performLayout 
flutter: #105    RenderObject.layout 
flutter: #106    RenderProxyBoxMixin.performLayout 
flutter: #107    RenderObject.layout 
flutter: #108    RenderProxyBoxMixin.performLayout 
flutter: #109    RenderObject.layout 
flutter: #110    RenderProxyBoxMixin.performLayout 
flutter: #111    RenderObject.layout 
flutter: #112    RenderProxyBoxMixin.performLayout 
flutter: #113    RenderObject.layout 
flutter: #114    RenderProxyBoxMixin.performLayout 
flutter: #115    RenderObject.layout 
flutter: #116    RenderProxyBoxMixin.performLayout 
flutter: #117    RenderObject.layout 
flutter: #118    RenderProxyBoxMixin.performLayout 
flutter: #119    RenderOffstage.performLayout 
flutter: #120    RenderObject.layout 
flutter: #121    RenderStack.performLayout 
flutter: #122    RenderObject._layoutWithoutResize 
flutter: #123    PipelineOwner.flushLayout 
flutter: #124    RendererBinding.drawFrame 
flutter: #125    WidgetsBinding.drawFrame 
flutter: #126    RendererBinding._handlePersistentFrameCallback 
flutter: #127    SchedulerBinding._invokeFrameCallback 
flutter: #128    SchedulerBinding.handleDrawFrame 
flutter: #129    SchedulerBinding._handleDrawFrame 
flutter: #133    _invoke  (dart:ui/hooks.dart:249:10)
flutter: #134    _drawFrame  (dart:ui/hooks.dart:207:3)
flutter: (elided 3 frames from package dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired: RenderTable#bbe39 relayoutBoundary=up12 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
flutter:   creator: Table ← DataTable ← Padding ← Padding ← Container ← Column ← Padding ← Container ←
flutter:     _SingleChildViewport ← IgnorePointer-[GlobalKey#f4e01] ← Semantics ← _PointerListener ← ⋯
flutter:   parentData: offset=Offset(0.0, 0.0) (can use size)
flutter:   constraints: BoxConstraints(0.0<=w<=378.0, 0.0<=h<=Infinity)
flutter:   size: MISSING
flutter:   specified column widths: {0: IntrinsicColumnWidth(flex: null), 1: IntrinsicColumnWidth(flex: null)}
flutter:   default column width: FlexColumnWidth(1.0)
flutter:   table size: 2×2
flutter:   column offsets: unknown
flutter:   row offsets: []
flutter: This RenderObject had the following descendants (showing up to depth 5):
flutter:     child (0, 0): RenderMouseRegion#91c60 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:       child: RenderSemanticsGestureHandler#010a4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:         child: RenderPointerListener#ad9b2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:           child: RenderConstrainedBox#1c7a0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:             child: RenderPadding#a8e58 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:     child (1, 0): RenderMouseRegion#ae366 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:       child: RenderSemanticsGestureHandler#7d648 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:         child: RenderPointerListener#087a0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:           child: RenderConstrainedBox#6cd5f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:             child: RenderPadding#34ea3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:     child (0, 1): RenderMouseRegion#5d58a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:       child: RenderSemanticsGestureHandler#7166e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:         child: RenderPointerListener#10dbf NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:           child: RenderConstrainedBox#242e9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:             child: RenderPadding#331d8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:     child (1, 1): RenderMouseRegion#b0d45 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:       child: RenderSemanticsGestureHandler#59f08 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:         child: RenderPointerListener#14521 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:           child: RenderConstrainedBox#272b3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter:             child: RenderPadding#2ae7a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

flutter: Another exception was thrown: RenderBox was not laid out: RenderTable#bbe39 relayoutBoundary=up12 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#1a5c5 relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#5ac96 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#f5a44 relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#b6a4c relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#922cb relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#c184c relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#8f5d7 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a8da2 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#d476f relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a1f46 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#34c59 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#922cb relayoutBoundary=up7 NEEDS-PAINT
flutter: Another exception was thrown: Updated layout information required for RenderMouseRegion#91c60 NEEDS-LAYOUT NEEDS-PAINT to calculate semantics.

0 个答案:

没有答案