diff --git a/packages/remix/lib/src/components/toast/toast_layer.dart b/packages/remix/lib/src/components/toast/toast_layer.dart index 21b9d6474..38b027a14 100644 --- a/packages/remix/lib/src/components/toast/toast_layer.dart +++ b/packages/remix/lib/src/components/toast/toast_layer.dart @@ -107,8 +107,14 @@ class ToastLayerState extends State implements ToastActions { } } -void showToast({required BuildContext context, required ToastEntry entry}) { - final toastState = context.findAncestorStateOfType(); +void showToast({ + required BuildContext context, + bool useRootNavigator = true, + required ToastEntry entry, +}) { + final toastState = useRootNavigator + ? context.findRootAncestorStateOfType() + : context.findAncestorStateOfType(); if (toastState == null) { throw FlutterError.fromParts([ diff --git a/packages/remix/lib/src/core/remix_app.dart b/packages/remix/lib/src/core/remix_app.dart index e9163a19a..3f6d49fd2 100644 --- a/packages/remix/lib/src/core/remix_app.dart +++ b/packages/remix/lib/src/core/remix_app.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart' as m; import 'package:flutter/widgets.dart'; +import '../components/toast/toast.dart'; import 'theme/remix_theme.dart'; //ignore: avoid-unnecessary-stateful-widgets @@ -123,13 +124,15 @@ class _RemixAppState extends State { return RemixTheme( theme: widget.theme, darkTheme: widget.darkTheme ?? widget.theme, - child: widget.builder != null - ? Builder( - builder: (BuildContext context) { - return widget.builder!(context, child); - }, - ) - : (child ?? const SizedBox.shrink()), + child: ToastLayer( + child: widget.builder != null + ? Builder( + builder: (BuildContext context) { + return widget.builder!(context, child); + }, + ) + : (child ?? const SizedBox.shrink()), + ), ); }