SliverGrid中的flutter UI渲染库错误


body: Container(
width: _maxScreenWidth,
child: SafeArea(
child:Form(
key: formKey,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 160.0,
padding: EdgeInsets.symmetric(vertical: 15.0,horizontal: 15),
child: CustomScrollView(
scrollDirection: Axis.horizontal,
slivers: <Widget>[
SliverPadding(
padding: const EdgeInsets.all(10),
sliver: _buildContent(urls),
)
],
),
),
SizedBox(height: 20.0,)  ,
],
),
),
),
),
),

SliverGrid _buildContent(List<String> urls) {
return SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 150,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return PortfolioGalleryImageWidget(urls: urls[index],
onImageTap: () =>
Navigator.push(context,
_createGalleryDetail(urls, index),
),
);
},
childCount: urls.length,
),
);

}

错误

=============呈现库捕获到异常=====================================================performLayout()过程中引发了以下断言:SliverGeometry无效:;scrollExtent";为负数。

返回有问题的几何体的RenderSliver为:RenderSliverGrid#ee36d relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT…parentData:paintOffset=偏移(0.0,0.0)(可以使用大小)…约束:SliverConstraints(AxisDirection.right,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0,remainingPaintExtent:371.4,crossSaxExtent:110.0,crossSAxisDirection:AxisDirection.down,viewportMainAxisExtent:381.4,remaining CacheExtent:621.4,cacheOrigin:0.0)…几何体:SliverGeometry(滚动范围:-10.0,隐藏,最大PaintExtent:-10.0)…滚动范围:-10.0隐藏的…最大绘画范围:-10.0…当前没有孩子导致错误的相关小部件是:SliverGridfile:///Users/gagansingh/FlutterProjects/firebase_app/lib/fullImageView/PortfolioGallarySubPage.dart:441:12当抛出异常时,这是堆栈:#0 SliverGeometry.debugAssertIsValid..verify(包:flutter/src/rerendering/slacp.dart:712:9)#1 SliverGeometry.debugAssertIsValid#2 SliverGeometry.debugAssertIsValid(软件包:flutter/src/rendering/slacp.dart:751:6)#3 RenderSliver.debugAssertDoesMeetConstrains(包:flutter/src/rendering/slacp.dart:1206:22)#4 RenderObject.layout.(包:flutter/src/rendering/object.dart:1787:9)。。。激发异常时正在处理以下RenderObject:RenderSiverGrid#ee36d relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT…parentData:paintOffset=偏移(0.0,0.0)(可以使用大小)…约束:SliverConstraints(AxisDirection.right,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0,remainingPaintExtent:371.4,crossSaxExtent:110.0,crossSAxisDirection:AxisDirection.down,viewportMainAxisExtent:381.4,remaining CacheExtent:621.4,cacheOrigin:0.0)…几何体:SliverGeometry(滚动范围:-10.0,隐藏,最大PaintExtent:-10.0)…滚动范围:-10.0隐藏的…最大绘画范围:-10.0…当前没有孩子RenderObject:RenderSliverGrid#ee36d relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINTparentData:paintOffset=偏移(0.0,0.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0,remainingPaintExtent:371.4,crossSaxExtent:110.0,crossSAxisDirection:AxisDirection.down,viewportMainAxisExtent:381.4,remainngCacheExtent:621.4,cacheOrigin:0.0)几何体:SliverGeometry(scrollExtent:-10.0,隐藏,maxPaintExtent:-10)滚动范围:-10.0隐藏的最大绘画范围:-10.0当前没有孩子

=============呈现库捕获到异常=====================================================SliverGeometry无效:;maxPaintExtent";小于";paintExtent";。返回有问题的几何体的RenderSliver为:RenderSliverPadding#d3dd8 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATEparentData:paintOffset=偏移(0.0,0.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right、GrowthDirection.forward、ScrollDirection.idle、scrollOffset:0.0、remainingPaintExtent:381.4、crossAxisExtent:130.0、crossaxDirection:AxisDirection.down、viewportMainAxisExtent:381.4、remaining CacheExtent:631.4、cacheOrigin:0.0)几何体:SliverGeometry(滚动范围:10.0,paintExtent:20.0,maxPaintExtent:10.0,cacheExtent:20.00)scrollExtent:10.0油漆范围:20.0最大绘画范围:10.0cacheExtent:20.0填充:EdgeInsets.all(10.0)text方向:ltrchild:RenderSliverGrid#ee36d relayoutBoundary=up2 NEEDS-PAINTparentData:paintOffset=偏移(10.0,10.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0,remainingPaintExtent:371.4,crossSaxExtent:110.0,crossSAxisDirection:AxisDirection.down,viewportMainAxisExtent:381.4,remainngCacheExtent:621.4,cacheOrigin:0.0)几何体:SliverGeometry(scrollExtent:-10.0,隐藏,maxPaintExtent:-10)滚动范围:-10.0隐藏的最大绘画范围:-10.0当前没有孩子导致错误的相关小部件是:SliverPaddingfile:///Users/gagansingh/FlutterProjects/firebase_app/lib/fullImageView/PortfolioGallarySubPage.dart:182:29激发异常时正在处理以下RenderObject:RenderSiverPadding#d3dd8 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATEparentData:paintOffset=偏移(0.0,0.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right、GrowthDirection.forward、ScrollDirection.idle、scrollOffset:0.0、remainingPaintExtent:381.4、crossAxisExtent:130.0、crossaxDirection:AxisDirection.down、viewportMainAxisExtent:381.4、remaining CacheExtent:631.4、cacheOrigin:0.0)几何体:SliverGeometry(滚动范围:10.0,paintExtent:20.0,maxPaintExtent:10.0,cacheExtent:20.00)scrollExtent:10.0油漆范围:20.0最大绘画范围:10.0cacheExtent:20.0填充:EdgeInsets.all(10.0)text方向:ltrchild:RenderSliverGrid#ee36d relayoutBoundary=up2 NEEDS-PAINTparentData:paintOffset=偏移(10.0,10.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0,remainingPaintExtent:371.4,crossSaxExtent:110.0,crossSAxisDirection:AxisDirection.down,viewportMainAxisExtent:381.4,remainngCacheExtent:621.4,cacheOrigin:0.0)几何体:SliverGeometry(scrollExtent:-10.0,隐藏,maxPaintExtent:-10)滚动范围:-10.0隐藏的最大绘画范围:-10.0当前没有孩子RenderObject:RenderSiverPadding#d3dd8 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATEparentData:paintOffset=偏移(0.0,0.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right、GrowthDirection.forward、ScrollDirection.idle、scrollOffset:0.0、remainingPaintExtent:381.4、crossAxisExtent:130.0、crossaxDirection:AxisDirection.down、viewportMainAxisExtent:381.4、remaining CacheExtent:631.4、cacheOrigin:0.0)几何体:SliverGeometry(滚动范围:10.0,paintExtent:20.0,maxPaintExtent:10.0,cacheExtent:20.00)scrollExtent:10.0油漆范围:20.0最大绘画范围:10.0cacheExtent:20.0填充:EdgeInsets.all(10.0)text方向:ltrchild:RenderSliverGrid#ee36d relayoutBoundary=up2 NEEDS-PAINTparentData:paintOffset=偏移(10.0,10.0)(可以使用大小)约束:SliverConstraints(AxisDirection.right,GrowthDirection.forward,ScrollDirection.idle,scrollOffset:0.0,remainingPaintExtent:371.4,crossSaxExtent:110.0,crossSAxisDirection:AxisDirection.down,viewportMainAxisExtent:381.4,remainngCacheExtent:621.4,cacheOrigin:0.0)几何体:SliverGeometry(scrollExtent:-10.0,隐藏,maxPaintExtent:-10)滚动范围:-10.0隐藏的最大绘画范围:-10.0当前没有孩子

=============呈现库捕获到异常=====================================================SliverGeometry无效:;maxPaintExtent";小于";paintExtent";。

Remove:scrollDirection:Axis.horizontal,然后再加上物理学,你的问题就会得到解决。

CustomScrollView(
physics: const NeverScrollableScrollPhysics()
slivers: <Widget>[
SliverPadding(
padding: const EdgeInsets.all(10),
sliver: _buildContent(urls),
)

最新更新