skip to Main Content
return Scaffold(
        appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text("Se connecter"),
        backgroundColor: Colors.red,
        ),
        body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: 
        Container(
          margin: EdgeInsets.all(24),
          decoration: BoxDecoration(color: Colors.white),
          child : 
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
            ListView(
              scrollDirection: Axis.horizontal,
              children: <Widget>[
                Container(
                  width: 160.0,
                  color: Colors.red,
                ),
                Container(
                  width: 160.0,
                  color: Colors.blue,
                ),
              ]
            ),
            TextField(  
                decoration: InputDecoration(  
                    border: OutlineInputBorder(),  
                    labelText: 'Email',  
                    hintText: 'Enter email',  
                    contentPadding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
                ),  
            ),
            TextField(  
                obscureText: true,  
                decoration: InputDecoration(  
                    border: OutlineInputBorder(),  
                    labelText: 'Password',  
                    hintText: 'Enter Password',  
                    contentPadding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
                ),  
            ),

            Text(
                '10',
                style: Theme.of(context).textTheme.headlineMedium,
            ),
            // ↓ Add this.
            ElevatedButton(
                style: ElevatedButton.styleFrom(
                    primary: Colors.red,
                ),
                onPressed: () async {
                print('button pressed!');
                Map<String,String?> infos = {
                    'app_id' : dotenv.env['app_id'],
                    'database' : dotenv.env['database'],
                    'mail' : dotenv.env['mail'],
                    'pass' : dotenv.env['pass'],
                    //'debug-mr' : dotenv.env['debug-mr'],
                };
                var a = await HttpGet('/auth', infos);
                Map<String, dynamic> map = jsonDecode(a.body);
                print(map['auth_mode']);
                },
                child: Text('Next'),
            ),
            ],
        ),
        ),
        ),
        floatingActionButton: FloatingActionButton(
            onPressed: null,
            tooltip: 'Increment',
            child: const Icon(Icons.add),
        ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

I want first to create a column in 2 columns in the first row of the view, then display in differents rows differents components after the second row… each one one row

..but there is not that

I expect that it appears anything of my screen view, or nothing is displayed, all is white

Thanks in advance if you are able to help me

2

Answers


  1. Please add shrinkWrap = true inside ListView,
    Or Wrap Expand widget outside ListView,
    If scrollDirection = axis.horizontal, Please Wrap LisView in SizeBox and set Height for SizeBox

    Login or Signup to reply.
  2. Because of Column [ ListView...] Firstly check Unbounded height / width | Decoding Flutter.

    For your case, Container doesn’t have any height.

    try providing height.

    You can wrap the ListView with Expanded widget, it will get available space for ListView.

    class _FR43State extends State<FR43> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            // Here we take the value from the MyHomePage object that was created by
            // the App.build method, and use it to set our appbar title.
            title: Text("Se connecter"),
            backgroundColor: Colors.red,
          ),
          body: Center(
            // Center is a layout widget. It takes a single child and positions it
            // in the middle of the parent.
            child: Container(
              margin: EdgeInsets.all(24),
              decoration: BoxDecoration(color: Colors.white),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Expanded(
                    child: ListView(
                        scrollDirection: Axis.horizontal,
                        children: <Widget>[
                          Container(
                            width: 160.0,
                            height: 200,
                            color: Colors.red,
                          ),
                          Container(
                            width: 160.0,
                            height: 200,
                            color: Colors.blue,
                          ),
                        ]),
                  ),
                  TextField(
                    decoration: InputDecoration(
                      border: OutlineInputBorder(),
                      labelText: 'Email',
                      hintText: 'Enter email',
                      contentPadding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
                    ),
                  ),
                  TextField(
                    obscureText: true,
                    decoration: InputDecoration(
                      border: OutlineInputBorder(),
                      labelText: 'Password',
                      hintText: 'Enter Password',
                      contentPadding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
                    ),
                  ),
    
                  Text(
                    '10',
                    style: Theme.of(context).textTheme.headlineMedium,
                  ),
                  // ↓ Add this.
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      primary: Colors.red,
                    ),
                    onPressed: () async {
                      // print('button pressed!');
                      // Map<String,String?> infos = {
                      //     'app_id' : dotenv.env['app_id'],
                      //     'database' : dotenv.env['database'],
                      //     'mail' : dotenv.env['mail'],
                      //     'pass' : dotenv.env['pass'],
                      //     //'debug-mr' : dotenv.env['debug-mr'],
                      // };
                      // var a = await HttpGet('/auth', infos);
                      // Map<String, dynamic> map = jsonDecode(a.body);
                      // print(map['auth_mode']);
                    },
                    child: Text('Next'),
                  ),
                ],
              ),
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: null,
            tooltip: 'Increment',
            child: const Icon(Icons.add),
          ), // This trailing comma makes auto-formatting nicer for build methods.
        );
      }
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search