标签: sliver-grid

错误:SliverGeometry 无效:“scrollExtent”为负数。在 flutter Sliver 网格视图布局中

渲染库捕获异常

\n
The following assertion was thrown during performLayout():\nSliverGeometry is not valid: The "scrollExtent" is negative.\nThe RenderSliver that returned the offending geometry was: RenderSliverGrid#f9778 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT:\n  creator: SliverGrid \xe2\x86\x90 MediaQuery \xe2\x86\x90 SliverPadding \xe2\x86\x90 Viewport \xe2\x86\x90 IgnorePointer-[GlobalKey#15db4] \xe2\x86\x90\n    Semantics \xe2\x86\x90 _PointerListener \xe2\x86\x90 Listener \xe2\x86\x90 _GestureSemantics \xe2\x86\x90\n    RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#30301] \xe2\x86\x90 _PointerListener \xe2\x86\x90 Listener\n    \xe2\x86\x90 \xe2\x8b\xaf\n  parentData: paintOffset=Offset(0.0, 0.0) (can use size)\n  constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle,\n
Run Code Online (Sandbox Code Playgroud)\n

flutter sliver-grid

7
推荐指数
2
解决办法
6675
查看次数

如何为 SliverGrid 提供背景颜色?

For ListView or GridView we wrap it with Container. But how can I give background color to SliverGrid?

flutter flutter-sliver sliver-grid

5
推荐指数
1
解决办法
3553
查看次数

Flutter RenderObject 断言失败

我遇到以下错误:

======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
Updated layout information required for RenderIndexedSemantics#f51aa NEEDS-LAYOUT to calculate semantics.
'package:flutter/src/rendering/object.dart':
Failed assertion: line 2658 pos 12: '!_needsLayout'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-sliver sliver-grid

5
推荐指数
1
解决办法
2233
查看次数

flutter 中 ScrollExtent 为负值

我的 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 …
Run Code Online (Sandbox Code Playgroud)

flutter-layout sliver-grid

2
推荐指数
1
解决办法
2769
查看次数

如何在 SliverGrid 中使用 itemCount?

很可能我的 SliverGrid 概念完全错误,

我想要做的是,在 UI 方面,我想要 Flutter 中已经提供的可折叠 SliverAppBar。我的主要内容主体是来自 API 响应的一组图像,并且已经解析并加载到 List 变量中。

现在这是我的代码:

body: CustomScrollView(
          slivers: <Widget>[
            SliverAppBar(expandedHeight: 150.0, backgroundColor: Colors.green),
            SliverGrid(
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3
              ),
              delegate: SliverChildBuilderDelegate((BuildContext context, int index){
                return Padding(
                  padding: EdgeInsets.symmetric(horizontal: 2.0, vertical: 2.0),
                  child: InkWell(
                    child: Card(
                      elevation: 8.0,
                      child: FadeInImage.memoryNetwork(fit: BoxFit.cover,image: myimagelist[index].thumbnail, placeholder:kTransparentImage,fadeInCurve: Curves.bounceIn,),
                    ),
                  )
                );
              }),
            ),
          ],
        ),
Run Code Online (Sandbox Code Playgroud)

我想这可能是因为我无法告诉小部件我的数据有多长。对于 GridView.builderitemCount参数是有的,但 SliverGrid 没有这样的选项。在这里做什么?

dart flutter flutter-sliver sliver-grid

0
推荐指数
1
解决办法
3542
查看次数