Skip to content

Instantly share code, notes, and snippets.

@tetujin
Last active December 25, 2021 07:57
Show Gist options
  • Save tetujin/ec66ba447c0d0dfbf38bc7df06482823 to your computer and use it in GitHub Desktop.
Save tetujin/ec66ba447c0d0dfbf38bc7df06482823 to your computer and use it in GitHub Desktop.
final _textFieldController = TextEditingController();
Future<String?> _showTextInputDialog(BuildContext context) async {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('タイトル'),
content: TextField(
controller: _textFieldController,
decoration: const InputDecoration(hintText: "文字列を入力してください。"),
),
actions: <Widget>[
ElevatedButton(
child: const Text("キャンセル"),
onPressed: () => Navigator.pop(context),
),
ElevatedButton(
child: const Text('OK'),
onPressed: () => Navigator.pop(context, _textFieldController.text),
),
],
);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment