openModalAsync<T> static method
Opens modalId and returns a Future that completes with whatever
closeModalWithResult passes when the modal closes (null otherwise).
Implementation
static Future<T?> openModalAsync<T>(
GoRouter router,
NavigationStorage storage,
String modalId,
) {
final modalCompleters = storage.modalCompleters;
final existingCompleter = modalCompleters[modalId];
if (existingCompleter != null && !existingCompleter.isCompleted) {
existingCompleter.complete(null);
}
final completer = Completer<T?>();
modalCompleters[modalId] = completer;
openModal(router, modalId);
return completer.future;
}