'How to create gridview with user input in flutter?

I added text field for rows and columns for the user to input , now what should I specify in the set state of the button so that on clicking, it changes the grid according to the row and column user input.

TextEditingController row = TextEditingController();
  TextEditingController column = TextEditingController();

  int rowC = 2;
  int colC = 2;
.
.
Container(
                height: 300,
                child: Container(
                  padding: EdgeInsets.all(10),
                  child: GridView.builder(
                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: rowC,childAspectRatio: colC*rowC/2 ,crossAxisSpacing: 10,mainAxisSpacing: 10),
                    itemCount: 2,
                    itemBuilder: (ctx,index){
                      return Container(
                        margin: EdgeInsets.all(10),
                        child: RaisedButton(
                          onPressed: (){}
                            );
                          },
                          color: Colors.blue,
                          child: Text(index.toString()),
                        ),
             Card(
               elevation: 5,
               child: Container(
                 padding: EdgeInsets.all(10),
                 child: Column(
                   crossAxisAlignment: CrossAxisAlignment.end,
                 children: <Widget>[
                   TextField(
                     controller: row,
                     decoration: InputDecoration(labelText: 'Row'),
                   ),
                   TextField(
                     controller: column,
                     decoration: InputDecoration(labelText: 'Column'),
                   ),
                   FlatButton(onPressed: (){
                     rowC = int.parse(row.text);
                     colC = int.parse(column.text);
                     setState(() {  
                     });
                   },
                       child: Text('Add'))
                 ],
         
 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source