【问题标题】:Flutter Gridview is not visibleFlutter Gridview 不可见
【发布时间】:2019-02-08 11:53:00
【问题描述】:
  Widget build(BuildContext context) {
    return MaterialApp(
        home: new Scaffold(
          body: new Container(
          child: Padding(
            padding: EdgeInsets.fromLTRB(10.0,10.0, 10.0,10.0),
            child: Column(
              children: <Widget>[
                 timeslotsGrid()
         ],),),)));}

  Widget timeslotsGrid(){
    return Container(
child: GridView.count(
  primary: false,
  padding: const EdgeInsets.all(0.0),
  crossAxisSpacing: 10.0,
  crossAxisCount: 2,
  children: <Widget>[
    const Text('He\'d have you all unravel at the'),
    const Text('Heed not the rabble'),
    const Text('Sound of screams but the'),
    const Text('Who scream'),
  ],)   ),}

我正在flutter中实现gridview。我尝试使用上面的代码,但问题是网格根本不可见并且页面是空白的

【问题讨论】:

    标签: flutter


    【解决方案1】:

    将Container 更改为Expanded

    Widget timeSlotsGrid() {
        return Expanded(
          child: GridView.count(
            primary: false,
            padding: const EdgeInsets.all(0.0),
            crossAxisSpacing: 10.0,
            crossAxisCount: 2,
            children: <Widget>[
              const Text('He\'d have you all unravel at the'),
              const Text('Heed not the rabble'),
              const Text('Sound of screams but the'),
              const Text('Who scream'),
            ],
          ),
        );
      }
    

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 1970-01-01
      • 2021-08-09
      • 2011-07-19
      • 1970-01-01
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多