在我的 Flutter 应用程序的这一部分出现一个非常讨厌的错误,不知道为什么:
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
childAspectRatio: 4 / 3,
mainAxisSpacing: 30.0,
crossAxisSpacing: 20.0),
padding: EdgeInsets.only(left: 20),
scrollDirection: Axis.horizontal,
itemCount: products.length,
itemBuilder: (context, i) => ChangeNotifierProvider.value(
value: products[i],
child: Consumer<Product>(
builder: (context, product, _) {
return ProductCard(
product: product,
onSelected: (prod) {
setState(() {
products.forEach(
(item) {
item.isSelected = false;
},
);
prod.isSelected = true;
});
here's the error: SliverGeometry is not valid: The "scrollExtent" is negative.geometry: SliverGeometry(scrollExtent: -10.0, paintExtent: 20.0, maxPaintExtent: -10.0, cacheExtent: 20.0)
scrollExtent: -10.0
paintExtent: 20.0
maxPaintExtent: -10.0
cacheExtent: 20.0
填充:EdgeInsets(20.0, 0.0, 0.0, 0.0)
即使安装了 apk 但它不会运行,此错误也会阻止在 Android 上进行仿真。它在 iOS 上运行,但错误仍然存在。