问题
I'am trying to add TextField to a Dialog, but when the Keyboard appears, it gives an overflow.
My dialog Image
When the Keyboard shows up
Here How a part my code looks Like:
AlertDialog(
content: new ListView(
shrinkWrap: true,
children: <Widget>[
Text(
"How Would You Rate Our App?",
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
)
回答1:
You can simply use SingleChildScrollView:
AlertDialog(
content: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: <Widget>[
Text(
"How Would You Rate Our App?",
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
]
)
)
)
回答2:
Wrapping this code around a dialog fixed this issue for me:
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: const EdgeInsets.only(bottom: mediaQuery.viewInsets.bottom),
duration: const Duration(milliseconds: 300),
child: child);
}
}
来源:https://stackoverflow.com/questions/51498911/flutter-keyboard-overflow-with-my-dialog