Want to show a text field dialog without being covered by keyboard? Here is a quick example on how to use a FullScreenDialog, I hope this help and you should be able to modify it the way you want:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | import 'package:flutter/material.dart'; void main() { runApp(new MaterialApp(home: new FocusVisibilityDemo())); } class FocusVisibilityDemo extends StatefulWidget { @override _FocusVisibilityDemoState createState() => new _FocusVisibilityDemoState(); } class _FocusVisibilityDemoState extends State<FocusVisibilityDemo> { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text('Text Dialog Demo')), body: new Center( child: new RaisedButton( onPressed: _showDialog, child: new Text("Push Me"), ), ), ); } _showDialog() async { await showDialog<String>( context: context, child: new _SystemPadding(child: new AlertDialog( contentPadding: const EdgeInsets.all(16.0), content: new Row( children: <Widget>[ new Expanded( child: new TextField( autofocus: true, decoration: new InputDecoration( labelText: 'Full Name', hintText: 'eg. John Smith'), ), ) ], ), actions: <Widget>[ new FlatButton( child: const Text('CANCEL'), onPressed: () { Navigator.pop(context); }), new FlatButton( child: const Text('OPEN'), onPressed: () { Navigator.pop(context); }) ], ),), ); } } class _SystemPadding extends StatelessWidget { final Widget child; _SystemPadding({Key key, this.child}) : super(key: key); @override Widget build(BuildContext context) { var mediaQuery = MediaQuery.of(context); return new AnimatedContainer( padding: mediaQuery.viewInsets, duration: const Duration(milliseconds: 300), child: child); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.