My Dart compiler is complaining: Don't use 'BuildContext's across async gaps.
Future<void> check(int forwardCategory, BuildContext context) async {
...
final addDialogResponse = await showDialog<bool>(
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('Add relations?'),
content: Text(
"Add the following ${widget.relText2} relations:\n$relationsStr"),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('OK'),
),
],
),
);
...
}
How to rewrite this code to avoid this warning about displaying a boolean dialog? (And by the way, what's bad in using BuildContext
among async gaps?)