我希望有个美好的一天。我努力将ListView.builder包装在列中。 每次尝试修复它时,都会出现此异常:
The following RenderObject was being processed when the exception was fired:
flutter: RenderViewport#c3792 NEEDS-LAYOUT NEEDS-PAINT
flutter: creator: Viewport ← IgnorePointer-[GlobalKey#b696d] ← Semantics ← Listener ← _GestureSemantics ←
flutter: RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#65964] ← Listener ← _ScrollableScope
flutter: ← _ScrollSemantics-[GlobalKey#f3a27] ← Scrollable ← PrimaryScrollController ← ListView ← ⋯
flutter: parentData: <none> (can use size)
flutter: constraints: BoxConstraints(w=327.0, 0.0<=h<=Infinity)
flutter: size: MISSING
flutter: axisDirection: down
flutter: crossAxisDirection: right
flutter: offset: ScrollPositionWithSingleContext#60171(offset: 0.0, range: null..null, viewport: null,
flutter: ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics, IdleScrollActivity#63b9f,
flutter: ScrollDirection.idle)
flutter: anchor: 0.0
flutter: This RenderObject had the following descendants (showing up to depth 5):
flutter: RenderSliverPadding#e4dfb NEEDS-LAYOUT NEEDS-PAINT
flutter: RenderSliverList#17862 NEEDS-LAYOUT NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#c3792 NEEDS-LAYOUT NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#c3792 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#8fccb relayoutBoundary=up9 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#cbeea relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#0b306 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
这是我的代码:
Padding(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.builder(
itemCount: _messages.length,
itemBuilder: (context, position) {
print(_messages.length);
return Center(child: Text(_messages[position]));
}),
)
]))
如果有人可以帮助我,我将非常感激。