flutter - how to create forms in popup

后端 未结 3 746
攒了一身酷
攒了一身酷 2020-12-25 13:03

I want to create a form inside a pop-up with flutter like the image below: popup

3条回答
  •  失恋的感觉
    2020-12-25 14:05

    Using the rflutter_alert plugin rflutter_alert

    You must add the library as a dependency to your project.

     dependencies:
       rflutter_alert: ^1.0.3
    

    To open a popup, Let’s to be a function and do the following:

     _openPopup(context) {
        Alert(
            context: context,
            title: "LOGIN",
            content: Column(
              children: [
                TextField(
                  decoration: InputDecoration(
                    icon: Icon(Icons.account_circle),
                    labelText: 'Username',
                  ),
                ),
                TextField(
                  obscureText: true,
                  decoration: InputDecoration(
                    icon: Icon(Icons.lock),
                    labelText: 'Password',
                  ),
                ),
              ],
            ),
            buttons: [
              DialogButton(
                onPressed: () => Navigator.pop(context),
                child: Text(
                  "LOGIN",
                  style: TextStyle(color: Colors.white, fontSize: 20),
                ),
              )
            ]).show();
      }
    

    And call it this way

    onPressed: () {
      _openPopup(context),
    } 
    

提交回复
热议问题