I'm currently facing the following problem in my Flutter app:
This is my current layout. It contains 2 charts that I designed myself using a widget based on a render box.
If I click on the button at the bottom an AlertDialog should be displayed.
onTap: () {
showDialog<void>(
context: _context,
builder: (BuildContext context) {
/*
Additional code
*/
return StatefulBuilder(
builder: (context, setState) {
return AlertDialog(
title: 'Title',
content: MyDateField(
value: selectedDate,
minDate: minDate,
maxDate: maxDate,
onChanged: (DateTime? newValue) {
setState(() {
if (newValue != null) {
selectedDate = DateTime.utc(newValue.year, newValue.month, newValue.day);
}
});
}
),
actions: <Widget>[
TextButton(
style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge,
),
child: Text('Abbrechen'),
onPressed: () {
context.pop();
}
),
TextButton(
style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge,
),
child: Text('OK'),
onPressed: () {
/*
Additional code
*/
}
)
]
);
}
);
}
);
}
Instead of displaying the AlertDialog, parts of the lower chart, the complete upper chart and parts of the rest of the design are displayed graphically above it.
I think that the charts are repaint ("void paint(PaintingContext context, Offset offset)" is executed) and the AlertDialog is displayed before the charts are finished painting.
How can I prevent this or otherwise work around it?
EDIT: We tried to describe the problem in a simplified way. Unfortunately, it didn't work. I was looking for a solution that would delay the build of the AlertDialog until everything was rebuilt in the background.
It seems like this was a bug in Flutter. After an update to Flutter 3.27.2 3 days ago, the bug was gone.
It seems like this was a bug in Flutter. After an update to Flutter 3.27.2 3 days ago, the bug was gone.
EDIT: This error was still present in the version from 2 weeks ago and could be reliably reproduced. It also exists in a compiled version of the app that is still available now. This error no longer occurs in the new version after the update, although nothing else in the code has been changed. So it must have been due to this update.