[flutter] dialog prompt

💜Dabo (개발자 다보)·2020년 4월 9일
0

Flutter Widget

목록 보기
2/11

View

Prompt Code

Future<String> _asyncInputDialog(BuildContext context) async {
    var name = '';
    return showDialog<String>(
      context: context,
      barrierDismissible:
          false, // dialog is dismissible with a tap on the barrier
      builder: (context) {
        return AlertDialog(
          title: Text('Title'),
          content: Row(
            children: <Widget>[
              Expanded(
                  child: TextField(
                autofocus: true,
                decoration: InputDecoration(
                    labelText: 'Team Name', hintText: 'eg. bora'),
                onChanged: (value) {
                  name = value;
                },
              ))
            ],
          ),
          actions: <Widget>[
            FlatButton(
              child: const Text('CANCEL'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
            FlatButton(
              child: Text('Ok'),
              onPressed: () {
                Navigator.of(context).pop(name);
              },
            ),
          ],
        );
      },
    );
  }

used Prompt Code

...
	onTap: (value) async {
            if (value == "") {
              await _asyncInputDialog(context);
            }
            ...
          }
...

cf

https://androidkt.com/flutter-alertdialog-example/

profile
𝙸 𝚊𝚖 𝚊 𝚌𝚞𝚛𝚒𝚘𝚞𝚜 𝚍𝚎𝚟𝚎𝚕𝚘𝚙𝚎𝚛 𝚠𝚑𝚘 𝚎𝚗𝚓𝚘𝚢𝚜 𝚍𝚎𝚏𝚒𝚗𝚒𝚗𝚐 𝚊 𝚙𝚛𝚘𝚋𝚕𝚎𝚖. 🇰🇷👩🏻‍💻

0개의 댓글

Powered by GraphCDN, the GraphQL CDN