Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart Listview中的GridView导致;垂直视口的高度是无限的”;即使扩大_Dart_Flutter - Fatal编程技术网

Dart Listview中的GridView导致;垂直视口的高度是无限的”;即使扩大

Dart Listview中的GridView导致;垂直视口的高度是无限的”;即使扩大,dart,flutter,Dart,Flutter,我对颤振还是新手,正在尝试创建以下布局: 我已将布局分为3个主要组件: 标题小部件(带有“Title Here”的小部件) 信息文本小部件(带有图标和“信息在此显示”的小部件) (文本) 包含GridView.count中按钮的GridView将使包覆面提取为真 ...... return GridView.count( primary: false, shrinkWrap: true, ...... 您应该在Gridview中添加以下两行代码: shrinkWrap: tr

我对颤振还是新手,正在尝试创建以下布局:

我已将布局分为3个主要组件:

  • 标题小部件(带有“Title Here”的小部件)
  • 信息文本小部件(带有图标和“信息在此显示”的小部件) (文本)

  • 包含GridView.count中按钮的GridView将使包覆面提取为真

    ......
    return GridView.count(
        primary: false,
        shrinkWrap: true,
    ......
    

    您应该在Gridview中添加以下两行代码:

    shrinkWrap: true,   
    physics: ClampingScrollPhysics(),  
    
    因此,您的GridView应该如下所示:

    return GridView.count(
              shrinkWrap: true,   
              physics: ClampingScrollPhysics(),
              primary: false,
              crossAxisSpacing: 5.0,
              crossAxisCount: 3,
              children: <Widget>[
                BoxHQ(
                  height: 100.0,
                  text: "Overview",
                  icon: Icons.ac_unit,
                ),
                BoxHQ(
                  height: 100.0,
                  text: "Overview",
                  icon: Icons.ac_unit,
                ),
                BoxHQ(
                  height: 100.0,
                  text: "Overview",
                  icon: Icons.ac_unit,
                ),
              ]
          );
    
    返回GridView.count(
    收缩膜:对,
    物理:ClampingScrollPhysics(),
    主要:错误,
    交叉轴间距:5.0,
    交叉轴计数:3,
    儿童:[
    博克斯总部(
    高度:100.0,
    正文:“概述”,
    图标:Icons.ac_单元,
    ),
    博克斯总部(
    高度:100.0,
    正文:“概述”,
    图标:Icons.ac_单元,
    ),
    博克斯总部(
    高度:100.0,
    正文:“概述”,
    图标:Icons.ac_单元,
    ),
    ]
    );
    
    非常感谢您。如果不是因为你和杰克·孙,我永远也猜不到这是真的。谢谢大家!非常感谢。我对你感激不尽。如果不是因为你和@anmol.majhail,我永远也猜不到这是真的。谢谢大家!非常感谢。
    import 'package:flutter/material.dart';
    
    class BoxHQ extends StatefulWidget {
      final double height;
      final IconData icon;
      final String text;
    
      BoxHQ({Key key, @required this.height, @required this.icon, @required this.text}): super(key: key);
    
      @override
      _BoxHQState createState() => _BoxHQState();
    }
    
    class _BoxHQState extends State<BoxHQ> {
      @override
      Widget build(BuildContext context) {
        return Container(
          height: widget.height,
          width: double.infinity,
          padding: EdgeInsets.all(5.0),
          margin: EdgeInsets.all(7.0),
          decoration:  new BoxDecoration(
            borderRadius: new BorderRadius.all(const Radius.circular(10.0)),
            color: Colors.red,
          ),
          child: Column( // Replace with a Row for horizontal icon + text
            children: <Widget>[
              Icon(widget.icon == null? Icons.info : widget.icon, color: Theme.of(context).primaryColorLight, size: 50.0,),
              new Padding(padding: EdgeInsets.symmetric(vertical: 5.0)),
              Text(widget.text, style: new TextStyle(color: Theme.of(context).primaryColorLight, fontSize: 20.0),),
            ],
          ),
        );
      }
    }
    
    I/Choreographer( 6979): Skipped 35 frames!  The application may be doing too much work on its main thread.
    D/EGL_emulation( 6979): eglMakeCurrent: 0xa6cac080: ver 2 0 (tinfo 0x970aa0c0)
    I/flutter ( 6979): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
    I/flutter ( 6979): The following assertion was thrown during performResize():
    I/flutter ( 6979): Vertical viewport was given unbounded height.
    I/flutter ( 6979): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
    I/flutter ( 6979): viewport was given an unlimited amount of vertical space in which to expand. This situation
    I/flutter ( 6979): typically happens when a scrollable widget is nested inside another scrollable widget.
    I/flutter ( 6979): If this widget is always nested in a scrollable widget there is no need to use a viewport because
    I/flutter ( 6979): there will always be enough vertical space for the children. In this case, consider using a Column
    I/flutter ( 6979): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
    I/flutter ( 6979): the height of the viewport to the sum of the heights of its children.
    
    ......
    return GridView.count(
        primary: false,
        shrinkWrap: true,
    ......
    
    shrinkWrap: true,   
    physics: ClampingScrollPhysics(),  
    
    return GridView.count(
              shrinkWrap: true,   
              physics: ClampingScrollPhysics(),
              primary: false,
              crossAxisSpacing: 5.0,
              crossAxisCount: 3,
              children: <Widget>[
                BoxHQ(
                  height: 100.0,
                  text: "Overview",
                  icon: Icons.ac_unit,
                ),
                BoxHQ(
                  height: 100.0,
                  text: "Overview",
                  icon: Icons.ac_unit,
                ),
                BoxHQ(
                  height: 100.0,
                  text: "Overview",
                  icon: Icons.ac_unit,
                ),
              ]
          );