ListView Builder 中的 Flutter 断言失败错误
Flutter assertion failed Error in ListView Builder
我正在尝试学习 flutter,并且 beginner.I 正在尝试在 flutter 应用程序中列出我的购物车项目。以下是我的购物车代码,widget.but 当我尝试访问购物车时出现以下错误。谁能帮我解决这个问题。
import 'dart:html';
import 'package:distribution/Providers/ShoppingCartProvider.dart';
import 'package:distribution/models/ShoppingCart/CartItem.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../widgets/ShoppingCart/ShoppingCartItem.dart';
class ShoppingCartScreen extends StatelessWidget {
static const routeName = '/shoppingcart';
@override
Widget build(BuildContext context) {
final cart = Provider.of<ShoppingCartProvider>(context);
return Scaffold(
appBar: AppBar(
title: const Text('Your Cart'),
),
body: Column(
children: <Widget>[
Card(
margin: const EdgeInsets.all(15),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
children: <Widget>[
const Text('Total', style: TextStyle(fontSize: 20)),
const Spacer(),
Chip(
label: Text(
'$${cart.totalAmount}',
),
backgroundColor: Theme.of(context).primaryColor,
),
TextButton(
child: Text('ORDER NOW'),
onPressed: () {},
),
const SizedBox(height: 10),
Expanded(
child: ListView.builder(
itemCount: cart.items.length,
itemBuilder: (ctx, i) => ShoppingCartItem(
cart.items.values.toList()[i].id,
cart.items.keys.toList()[i],
cart.items.values.toList()[i].price,
cart.items.values.toList()[i].quantity,
cart.items.values.toList()[i].title,
),
),
)
],
))),
],
));
}
}
这是给我带来问题的部分
Expanded(
child: ListView.builder(
itemCount: cart.items.length,
itemBuilder: (ctx, i) => ShoppingCartItem(
cart.items.values.toList()[i].id,
cart.items.keys.toList()[i],
cart.items.values.toList()[i].price,
cart.items.values.toList()[i].quantity,
cart.items.values.toList()[i].title,
),
),
我的购物车插件代码
import 'package:distribution/Providers/ShoppingCartProvider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ShoppingCartItem extends StatelessWidget {
final String id;
final String productId;
final double price;
final int quantity;
final String title;
ShoppingCartItem(
this.id,
this.productId,
this.price,
this.quantity,
this.title,
);
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 4,
),
child: Padding(
padding:const EdgeInsets.all(8),
child: ListTile(
leading: CircleAvatar(
child: Padding(
padding:const EdgeInsets.all(5),
child: FittedBox(
child: Text('$$price'),
),
),
),
title: Text(title),
subtitle: Text('Total: '),
trailing: Text('x'),
),
),
);
}
}
购物车提供商
import 'package:distribution/models/ShoppingCart/CartItem.dart';
import 'package:flutter/foundation.dart';
class ShoppingCartProvider with ChangeNotifier {
// ignore: prefer_final_fields
Map<String, CartItem> _items = {};
Map<String, CartItem> get items {
return {..._items};
}
void addItem(
String productID,
double price,
String title,
) {
if (_items.containsKey(productID)) {
_items.update(
productID,
(existingitem) => CartItem(
id: existingitem.id,
title: existingitem.title,
quantity: existingitem.quantity + 1,
price: existingitem.price,
));
} else {
_items.putIfAbsent(
productID,
() => CartItem(
id: DateTime.now().toString(),
title: title,
price: price,
quantity: 1,
));
}
notifyListeners();
}
int get itemCount {
return _items == null ? 0 :_items.length;
}
double get totalAmount {
var total = 0.0;
_items.forEach((key, cartitem) {
total += cartitem.price * cartitem.quantity ;
});
return total;
}
void removeItem(String productId) {
_items.remove(productId);
notifyListeners();
}
}
购物车模型
import 'package:flutter/foundation.dart';
class CartItem {
final String id;
final String title;
final int quantity;
final double price;
CartItem({
@required this.id,
@required this.title,
@required this.quantity,
@required this.price
});
}
我收到错误
Error: Assertion failed: file:///Users/liyanaarachchi/flutter/packages/flutter/lib/src/rendering/box.dart:1927:12
hasSize
"RenderBox was not laid out: RenderPointerListener#60a6a NEEDS-LAYOUT NEEDS-PAINT"
at Object.throw_ [as throw] (http://localhost:64556/dart_sdk.js:5386:11)
at Object.assertFailed (http://localhost:64556/dart_sdk.js:5308:15)
at proxy_box.RenderPointerListener.new.get size [as size] (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4406:42)
at proxy_box.RenderPointerListener.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:545:26)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/custom_layout.dart.lib.js:304:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at material._RenderInkFeatures.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at material._RenderInkFeatures.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:2343:20)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3794:59)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at stack.RenderStack.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at stack.RenderStack.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/stack.dart.lib.js:683:19)
at stack.RenderStack.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderDecoratedBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderDecoratedBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at routes._RenderFocusTrap.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at routes._RenderFocusTrap.new.hitTest (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:19335:36)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3906:59)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29639:42
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at overlay$._RenderTheatre.new.hitTestChildren (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29635:28)
at overlay$._RenderTheatre.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderAbsorbPointer.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderAbsorbPointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderAbsorbPointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3989:79)
at proxy_box.RenderPointerListener.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderPointerListener.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:546:36)
at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/custom_paint.dart.lib.js:343:20)
at custom_paint.RenderCustomPaint.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at view.RenderView.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4953:58)
at binding.WidgetsFlutterBinding.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:5834:23)
at binding.WidgetsFlutterBinding.new.[_handlePointerEventImmediately] (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:333:14)
at binding.WidgetsFlutterBinding.new.handlePointerEvent (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:325:43)
at binding.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:314:14)
at binding.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:304:65)
at Object.invoke1 (http://localhost:64556/dart_sdk.js:202716:7)
at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:64556/dart_sdk.js:182673:15)
at _engine.PointerBinding.__.[_onPointerData] (http://localhost:64556/dart_sdk.js:183574:49)
at http://localhost:64556/dart_sdk.js:184046:26
at http://localhost:64556/dart_sdk.js:184011:16
at loggedHandler (http://localhost:64556/dart_sdk.js:183684:11)
Error: Assertion failed: file:///Users/liyanaarachchi/flutter/packages/flutter/lib/src/rendering/box.dart:1927:12
hasSize
"RenderBox was not laid out: RenderPointerListener#60a6a NEEDS-LAYOUT NEEDS-PAINT"
at Object.throw_ [as throw] (http://localhost:64556/dart_sdk.js:5386:11)
at Object.assertFailed (http://localhost:64556/dart_sdk.js:5308:15)
at proxy_box.RenderPointerListener.new.get size [as size] (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4406:42)
at proxy_box.RenderPointerListener.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:545:26)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/custom_layout.dart.lib.js:304:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at material._RenderInkFeatures.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at material._RenderInkFeatures.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:2343:20)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3794:59)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at stack.RenderStack.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at stack.RenderStack.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/stack.dart.lib.js:683:19)
at stack.RenderStack.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderDecoratedBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderDecoratedBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at routes._RenderFocusTrap.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at routes._RenderFocusTrap.new.hitTest (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:19335:36)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3906:59)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29639:42
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at overlay$._RenderTheatre.new.hitTestChildren (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29635:28)
只需将 shrinkWrap: true
添加到 ListView
即可解决此问题
我正在尝试学习 flutter,并且 beginner.I 正在尝试在 flutter 应用程序中列出我的购物车项目。以下是我的购物车代码,widget.but 当我尝试访问购物车时出现以下错误。谁能帮我解决这个问题。
import 'dart:html';
import 'package:distribution/Providers/ShoppingCartProvider.dart';
import 'package:distribution/models/ShoppingCart/CartItem.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../widgets/ShoppingCart/ShoppingCartItem.dart';
class ShoppingCartScreen extends StatelessWidget {
static const routeName = '/shoppingcart';
@override
Widget build(BuildContext context) {
final cart = Provider.of<ShoppingCartProvider>(context);
return Scaffold(
appBar: AppBar(
title: const Text('Your Cart'),
),
body: Column(
children: <Widget>[
Card(
margin: const EdgeInsets.all(15),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
children: <Widget>[
const Text('Total', style: TextStyle(fontSize: 20)),
const Spacer(),
Chip(
label: Text(
'$${cart.totalAmount}',
),
backgroundColor: Theme.of(context).primaryColor,
),
TextButton(
child: Text('ORDER NOW'),
onPressed: () {},
),
const SizedBox(height: 10),
Expanded(
child: ListView.builder(
itemCount: cart.items.length,
itemBuilder: (ctx, i) => ShoppingCartItem(
cart.items.values.toList()[i].id,
cart.items.keys.toList()[i],
cart.items.values.toList()[i].price,
cart.items.values.toList()[i].quantity,
cart.items.values.toList()[i].title,
),
),
)
],
))),
],
));
}
}
这是给我带来问题的部分
Expanded(
child: ListView.builder(
itemCount: cart.items.length,
itemBuilder: (ctx, i) => ShoppingCartItem(
cart.items.values.toList()[i].id,
cart.items.keys.toList()[i],
cart.items.values.toList()[i].price,
cart.items.values.toList()[i].quantity,
cart.items.values.toList()[i].title,
),
),
我的购物车插件代码
import 'package:distribution/Providers/ShoppingCartProvider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ShoppingCartItem extends StatelessWidget {
final String id;
final String productId;
final double price;
final int quantity;
final String title;
ShoppingCartItem(
this.id,
this.productId,
this.price,
this.quantity,
this.title,
);
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 4,
),
child: Padding(
padding:const EdgeInsets.all(8),
child: ListTile(
leading: CircleAvatar(
child: Padding(
padding:const EdgeInsets.all(5),
child: FittedBox(
child: Text('$$price'),
),
),
),
title: Text(title),
subtitle: Text('Total: '),
trailing: Text('x'),
),
),
);
}
}
购物车提供商
import 'package:distribution/models/ShoppingCart/CartItem.dart';
import 'package:flutter/foundation.dart';
class ShoppingCartProvider with ChangeNotifier {
// ignore: prefer_final_fields
Map<String, CartItem> _items = {};
Map<String, CartItem> get items {
return {..._items};
}
void addItem(
String productID,
double price,
String title,
) {
if (_items.containsKey(productID)) {
_items.update(
productID,
(existingitem) => CartItem(
id: existingitem.id,
title: existingitem.title,
quantity: existingitem.quantity + 1,
price: existingitem.price,
));
} else {
_items.putIfAbsent(
productID,
() => CartItem(
id: DateTime.now().toString(),
title: title,
price: price,
quantity: 1,
));
}
notifyListeners();
}
int get itemCount {
return _items == null ? 0 :_items.length;
}
double get totalAmount {
var total = 0.0;
_items.forEach((key, cartitem) {
total += cartitem.price * cartitem.quantity ;
});
return total;
}
void removeItem(String productId) {
_items.remove(productId);
notifyListeners();
}
}
购物车模型
import 'package:flutter/foundation.dart';
class CartItem {
final String id;
final String title;
final int quantity;
final double price;
CartItem({
@required this.id,
@required this.title,
@required this.quantity,
@required this.price
});
}
我收到错误
Error: Assertion failed: file:///Users/liyanaarachchi/flutter/packages/flutter/lib/src/rendering/box.dart:1927:12
hasSize
"RenderBox was not laid out: RenderPointerListener#60a6a NEEDS-LAYOUT NEEDS-PAINT"
at Object.throw_ [as throw] (http://localhost:64556/dart_sdk.js:5386:11)
at Object.assertFailed (http://localhost:64556/dart_sdk.js:5308:15)
at proxy_box.RenderPointerListener.new.get size [as size] (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4406:42)
at proxy_box.RenderPointerListener.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:545:26)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/custom_layout.dart.lib.js:304:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at material._RenderInkFeatures.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at material._RenderInkFeatures.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:2343:20)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3794:59)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at stack.RenderStack.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at stack.RenderStack.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/stack.dart.lib.js:683:19)
at stack.RenderStack.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderDecoratedBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderDecoratedBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at routes._RenderFocusTrap.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at routes._RenderFocusTrap.new.hitTest (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:19335:36)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3906:59)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29639:42
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at overlay$._RenderTheatre.new.hitTestChildren (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29635:28)
at overlay$._RenderTheatre.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderAbsorbPointer.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderAbsorbPointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderAbsorbPointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3989:79)
at proxy_box.RenderPointerListener.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderPointerListener.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:546:36)
at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/custom_paint.dart.lib.js:343:20)
at custom_paint.RenderCustomPaint.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at view.RenderView.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4953:58)
at binding.WidgetsFlutterBinding.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:5834:23)
at binding.WidgetsFlutterBinding.new.[_handlePointerEventImmediately] (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:333:14)
at binding.WidgetsFlutterBinding.new.handlePointerEvent (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:325:43)
at binding.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:314:14)
at binding.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:64556/packages/flutter/src/gestures/binding.dart.lib.js:304:65)
at Object.invoke1 (http://localhost:64556/dart_sdk.js:202716:7)
at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:64556/dart_sdk.js:182673:15)
at _engine.PointerBinding.__.[_onPointerData] (http://localhost:64556/dart_sdk.js:183574:49)
at http://localhost:64556/dart_sdk.js:184046:26
at http://localhost:64556/dart_sdk.js:184011:16
at loggedHandler (http://localhost:64556/dart_sdk.js:183684:11)
Error: Assertion failed: file:///Users/liyanaarachchi/flutter/packages/flutter/lib/src/rendering/box.dart:1927:12
hasSize
"RenderBox was not laid out: RenderPointerListener#60a6a NEEDS-LAYOUT NEEDS-PAINT"
at Object.throw_ [as throw] (http://localhost:64556/dart_sdk.js:5386:11)
at Object.assertFailed (http://localhost:64556/dart_sdk.js:5308:15)
at proxy_box.RenderPointerListener.new.get size [as size] (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4406:42)
at proxy_box.RenderPointerListener.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:545:26)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/custom_layout.dart.lib.js:304:19)
at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at material._RenderInkFeatures.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at material._RenderInkFeatures.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:2343:20)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3794:59)
at http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8537:44
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at stack.RenderStack.new.defaultHitTestChildren (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8533:30)
at stack.RenderStack.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/stack.dart.lib.js:683:19)
at stack.RenderStack.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderDecoratedBox.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderDecoratedBox.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3327:24
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3324:21)
at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3317:19)
at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at routes._RenderFocusTrap.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at routes._RenderFocusTrap.new.hitTest (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:19335:36)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at proxy_box.RenderOffstage.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:3906:59)
at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:64556/packages/flutter/src/rendering/proxy_box.dart.lib.js:448:56)
at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:4651:28)
at http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29639:42
at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:64556/packages/flutter/src/rendering/layer.dart.lib.js:8267:19)
at overlay$._RenderTheatre.new.hitTestChildren (http://localhost:64556/packages/flutter/src/widgets/widget_inspector.dart.lib.js:29635:28)
只需将 shrinkWrap: true
添加到 ListView