Commit e507622
Changed files (2)
lib
components
lib/components/dialoges/fullscreen_dialoge.dart
@@ -12,6 +12,7 @@ class FullscreenDialoge extends StatelessWidget {
required this.bottomAppBar,
this.closeIcon = Icons.close,
this.actions = const <Widget>[],
+ this.closeCallback,
});
/// The primary content of the dialoge.
@@ -24,6 +25,10 @@ class FullscreenDialoge extends StatelessWidget {
/// Setting this icon to null will hide the button entirely.
final IconData? closeIcon;
+ /// Callback that is called after the user pressed the [closeIcon] but before
+ /// popping the scope.
+ final void Function()? closeCallback;
+
/// Primary content of the text button at the right end of the app bar.
///
/// Usually `localizations.btnSave`
lib/components/dialoges/import_preview_dialoge.dart
@@ -72,18 +72,11 @@ class _ImportPreviewDialogeState extends State<ImportPreviewDialoge> {
}
}
- @override
- void dispose() {
- if(_showingError) {
- SchedulerBinding.instance.addPostFrameCallback(
- // TODO: add on close hook to dialoge and remove anti-pattern
- (_) => messenger.removeCurrentMaterialBanner(),);
- }
- super.dispose();
- }
-
@override
Widget build(BuildContext context) => FullscreenDialoge(
+ closeCallback: () {
+ if(_showingError) messenger.removeCurrentMaterialBanner();
+ },
bottomAppBar: widget.bottomAppBar,
actionButtonText: AppLocalizations.of(context)!.import,
onActionButtonPressed: (_showingError) ? null : () {