Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Gridview is not visible

Tags:

flutter

  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'),
  ],)   ),}

I am implementing gridview in flutter.I tried by using the above code but the issue is the grid is not at all visible and the page is blank

like image 369
Vishali Avatar asked Jan 02 '23 07:01

Vishali


1 Answers

Change Container to 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'),
        ],
      ),
    );
  }
like image 66
Günter Zöchbauer Avatar answered Feb 05 '23 01:02

Günter Zöchbauer