I have successive Alert Dialogs that appear after a button is pressed. When the second dialog displays, there’s a brief "FLT: A RenderFlex overflowed by 46 pixels on the bottom." that immediately goes away in a fraction of a second. This seems to only occurs when the vertical size of the second dialog is bigger than the first dialog. If the second dialog is smaller than the first, there is no error.
I think I’m correctly popping the first dialog. The first dialog method references a TextEditingController that is part of the parent widget class, which I believe I’m clearing correctly.
I don’t understand why I get this brief overflow error. It goes away immediately. Everything works otherwise. I see it on the android emulator and in the debug console. Is this a flutter bug or am I doing something stupid.
Basically I’m doing this
class _ParentWidgetState extends State<ParentWidget> {
late TextEditingController controller;
// init, dispose, build, blah blah...
ElevatedButton(
blahBlah: ...
onPressed: () async {
someText = await firstDialog();
await secondDialog(someText);
}
}
Future<String?> firstDialog() {
return showDialog<String>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Enter something'),
content: TextField(
decoration: const InputDecoration(
hintText: 'Enter something'),
autofocus: true,
controller: controller,
onSubmitted: (_) {
Navigator.of(context).pop(controller.text);
controller.clear();
}),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(controller.text);
controller.clear();
},
child: const Text('SUBMIT'))
],
),
);
}
Future<bool?> secondDialog(String someText) => showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(someText),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('Blah blah blah'),
const SizedBox(
height: 8,
),
const Text('Blah blah blah'),
const SizedBox(
height: 8,
),
const Text('Blah blah blah'),
const SizedBox(
height: 8,
),
const Text('Blah blah blah'),
],
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
},
child: const Text('Continue')),
],
);
});
2
Answers
I have made an example and I don’t have this error, maybe this example can help you. I don’t get the error you mentioned.
Here you go. You can copy this source code & paste it into the
main.dart
file and run it. Don’t forget to look at the attached output below the source code.Output: