How to add the widgets dynamically to column in Flutter?

后端 未结 4 1025
日久生厌
日久生厌 2021-02-08 10:55

I have added a few widgets inside the ListView. So that I can scroll all widgets. Now I required to add one more widget to the ListView to load the li

4条回答
  •  太阳男子
    2021-02-08 11:41

    import 'package:flutter/material.dart';
    
    class LoginRegisterPage extends StatefulWidget {
      @override
      _LoginRegisterPageState createState() => _LoginRegisterPageState();
    }
    
    class _LoginRegisterPageState extends State {
      @override
      Widget build(BuildContext context) {
        return new Scaffold(
          appBar: AppBar(
            title: Text("App"),
          ),
          body: new Container(
            margin: EdgeInsets.all(15.0),
            child: new Form(
              child: new Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: createInputs() + createButtons(),
              ),
              ),
          ),
        );
      } 
    
      List createInputs(){
        return{
          SizedBox(height: 10.0),
          logo(),
          SizedBox(height: 20.0),
          new TextFormField(
            decoration: new InputDecoration(labelText: 'Email'),
          ),
    
          SizedBox(height: 10.0),
          new TextFormField(
            decoration: new InputDecoration(labelText: 'Passwors')
          ),
          SizedBox(height: 20.0), 
        };
      }
    
      Widget logo(){
          return new Hero(        
            tag:'hero',
            child: new CircleAvatar(
              backgroundColor:Colors.transparent,
              radius: 110.0,
              child: Image.asset("images\logo.PNG"),          
            ),         
            );
        }
    
        List createButtons(){
        return{
          new RaisedButton(
            child: new Text("Login", style: new TextStyle(fontSize: 20.0),),
            textColor: Colors.pink,         
            onPressed: () {          
            },
            ),  
    
            new FlatButton(
            child: new Text("Already not have an account?", style: new TextStyle(fontSize: 14.0),),
            textColor: Colors.white,         
            onPressed: () {
            }, 
            )  
        };
      }
    }
    

提交回复
热议问题