简体   繁体   English

断言失败:第 1979 行第 12 行:'hasSize'

[英]Failed assertion: line 1979 pos 12: 'hasSize'

RenderBox was not laid out: RenderIgnorePointer#370eb relayoutBoundary=up25 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 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. RenderBox 未布置:RenderIgnorePointer#370eb relayoutBoundary=up25 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 断言表明框架本身存在错误,或者我们应该在此错误消息中提供更多信息以帮助您确定和修复根本原因。

import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import '../models/grid_model.dart';

class GridViewData extends StatefulWidget {
  final VoidCallback onPressed;

  const GridViewData({Key? key, required this.onPressed}) : super(key: key);

  @override
  State<GridViewData> createState() => _GridViewDataState();
}

class _GridViewDataState extends State<GridViewData> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: widget.onPressed,
      child: GridView.custom(
        physics: const BouncingScrollPhysics(),
        gridDelegate: SliverWovenGridDelegate.count(
          crossAxisCount: 2,
          mainAxisSpacing: 3,
          crossAxisSpacing: 10,
          pattern: [
            const WovenGridTile(0.7),
            const WovenGridTile(
              4 / 5,
            ),
          ],
        ),
        childrenDelegate: SliverChildBuilderDelegate(
            childCount: imageList.length,
                (context, index) {
              return Container(
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage(imageList[index].image),

                  ),
                ),
              );
                }),
      ),
    );
  }
}

答案是我从我被称为 GridView 类的正文中删除了 SingleChildScrollView,因为 GridView 本身是一个可滚动的小部件,这就是它给出错误的原因

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 失败的断言:第 551 行 pos 12:“child.hasSize”:不正确 - Failed assertion: line 551 pos 12: 'child.hasSize': is not true 颤振错误:断言失败:第 1785 行 pos 12:&#39;hasSize&#39; - Flutter error:Failed assertion: line 1785 pos 12: 'hasSize' 失败的断言:第 549 行 pos 12:“child.hasSize”:不正确 - Failed assertion: line 549 pos 12: 'child.hasSize': is not true 在“Row”中渲染 ListTile 时出现错误“断言失败:第 1687 行 pos 12:'hasSize'” - Get an error `Failed assertion: line 1687 pos 12: 'hasSize'` when render ListTile inside `Row` 错误:RenderBox 未布局,断言失败:第 1940 行 pos 12:'hasSize' - Error: RenderBox was not laid out, Failed assertion: line 1940 pos 12: 'hasSize' 失败的断言:第 5070 行 pos 12:&#39;<optimized out> &#39;: 不是真的 - Failed assertion: line 5070 pos 12: '<optimized out>': is not true 断言行 5120 pos 12 失败:'child = _child' 不是真的 - Failed assertion line 5120 pos 12: 'child = _child' is not true 失败的断言:第 6075 行 pos 12:&#39;child == _child&#39;:不是真的 - Failed assertion: line 6075 pos 12: 'child == _child': is not true 断言失败:第 125 行第 12 行:&#39;assertMidButtonStyles(navBarStyle, items!.length)&#39; - Failed assertion: line 125 pos 12: 'assertMidButtonStyles(navBarStyle, items!.length)' 失败的断言:第 1696 行 pos 12:&#39;center!.parent == this&#39;:不是真的 - Failed assertion: line 1696 pos 12: 'center!.parent == this': is not true
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM