Vertical viewport was given unbounded height

后端 未结 10 1175
不思量自难忘°
不思量自难忘° 2020-11-30 22:30

This is my code:

  @override
  Widget build(BuildContext context) {
    return new Material(
      color: Colors.deepPurpleAccent,
      child: new Column(
           


        
相关标签:
10条回答
  • 2020-11-30 22:51

    This situation typically happens when a scrollable widget is nested inside another scrollable widget.

    In my case i use GridView inside of Column and that error throws.

    GridView widget has shrinkWrap property/named parameter, to set it true my problem is fixed.

    GridView.count(
      shrinkWrap: true,
      // rest of code
    )
    
    0 讨论(0)
  • 2020-11-30 22:51

    Don't use Column for single child alignment. Use Align instead.

        new Align(
          alignment: Alignment.topCenter,
          child: new GridView(),
        )
    
    0 讨论(0)
  • 2020-11-30 22:53

    put grid view inside Flexible or Expanded widget

    return new Material(
        color: Colors.deepPurpleAccent,
        child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children:<Widget>[
             Flexible(
              child:  GridView.count(crossAxisCount: _column,children: new List.generate(_row*_column, (index) {
              return new Center(
                 child: new CellWidget(),
              );
            }),))]
        )
    );
    
    0 讨论(0)
  • 2020-11-30 22:56

    Although shrinkWrap do the thing, but you can't scroll in ListView.

    If you want scrolling functionality, you can add physics property:

    ListView.builder(
        scrollDirection: Axis.vertical,
        shrinkWrap: true,
        physics: ScrollPhysics(),
    ...
    
    0 讨论(0)
提交回复
热议问题