Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - How to make a column screen scrollable

I'm building a flutter app with a Login Screen. On focus on the text field(s), the screen is overflowed and i cannot scroll. I've tried using a ListView.builder, but that just gives a renderBox error, and the regular ListView doesn't work

Screen Screen on Text Input

The widget structure is like this

-scafold    - body      - container        - column                - form               - column                   - textInput                   - textInput                   - container                - container               - row                  - raisedButton 

Thank You in advance !!

like image 686
Kingsley CA Avatar asked Aug 28 '18 08:08

Kingsley CA


People also ask

How do I scroll the whole screen in Flutter?

to your ListView. shrinkWrap: true, scrollDirection: Axis. vertical, to your ListView.

How do you make the GridView scrollable in Flutter?

Add this line inside your GridView to allow scrolling physics: ScrollPhysics(), Add this line inside your GridView to disable scrolling physics: NeverScrollableScrollPhysics(), Through many examples, we learned how to resolve the Gridview Not Scrolling Flutter problem.


2 Answers

The ListView solution should work, but at the time of writing, it suffers from the crash listed here. Another way to achieve the same thing without this crash is to use a SingleChildScrollView:

return new Container(   child: new SingleChildScrollView(     child: new Column(       children: <Widget>[         _showChild1(),         _showChild2(),         ...         _showChildN()       ]     )   ) );  
like image 145
Rob Lyndon Avatar answered Sep 28 '22 15:09

Rob Lyndon


try this Code: Its Using ListView

    class Home extends StatelessWidget {   @override      Widget build(BuildContext context) {         // TODO: implement build         return Scaffold(           body: Center(             child: ListView(               shrinkWrap: true,               padding: EdgeInsets.all(15.0),               children: <Widget>[                 Center(                   child: Card(                     elevation: 8.0,                     child: Container(                       padding: EdgeInsets.all(10.0),                       child: Column(                         children: <Widget>[                           TextField(                             decoration: InputDecoration(                               prefixIcon: Icon(Icons.person),                               labelText: "Username or Email",                             ),                           ),                           SizedBox(                             height: 15.0,                           ),                           TextField(                             decoration: InputDecoration(                               prefixIcon: Icon(Icons.lock),                               labelText: "Password",                             ),                           ),                           SizedBox(                             height: 15.0,                           ),                           Material(                             borderRadius: BorderRadius.circular(30.0),                             //elevation: 5.0,                             child: MaterialButton(                               onPressed: () => {},                               minWidth: 150.0,                               height: 50.0,                               color: Color(0xFF179CDF),                               child: Text(                                 "LOGIN",                                 style: TextStyle(                                   fontSize: 16.0,                                   color: Colors.white,                                 ),                               ),                             ),                           )                         ],                       ),                     ),                   ),                 ),                 SizedBox(                   height: 25.0,                 ),                 Row(                   children: <Widget>[                     Expanded(child: Text("Don't Have a Account?")),                     Text("Sign Up",                         style: TextStyle(                           color: Colors.blue,                         )),                   ],                 ),               ],             ),           ),           bottomNavigationBar: Padding(             padding: EdgeInsets.all(10.0),             child: Row(               mainAxisAlignment: MainAxisAlignment.center,               children: <Widget>[                 Expanded(                     child: RaisedButton(                       padding: EdgeInsets.all(15.0),                       onPressed: () {},                       color: Colors.white,                       shape: RoundedRectangleBorder(                           borderRadius: BorderRadius.circular(                             32.0,                           ),                           side: BorderSide(color: Color(0xFF179CDF))),                       child: Text(                         "SKIP SIGN UP FOR NOW",                         style:                         TextStyle(fontSize: 18.0, color: Color(0xFF179CDF)),                       ),                     )),               ],             ),           ),         );       }     } 
like image 37
anmol.majhail Avatar answered Sep 28 '22 17:09

anmol.majhail