fix: pop properly to overview screen after creating post

This commit is contained in:
Jacques 2024-12-09 16:27:14 +01:00
parent f0c1c265b3
commit 7262729a04

View file

@ -97,19 +97,21 @@ class _FlutterTimelineNavigatorUserstoryState
options: widget.options, options: widget.options,
onTapCreatePost: (post) async { onTapCreatePost: (post) async {
await widget.options.onTapCreatePostInOverview?.call(post) ?? await widget.options.onTapCreatePostInOverview?.call(post) ??
await _pushAndRemoveUntil(_timelineScreenWidget()); _pushAndRemoveUntil(_timelineScreenWidget());
}, },
); );
Future<void> _push(Widget screen) async { Future<void> _push(Widget screen) async {
await Navigator.of(context) await Navigator.of(context).push(
.push(MaterialPageRoute(builder: (context) => screen)); MaterialPageRoute(
} builder: (context) => screen,
settings: const RouteSettings(arguments: "popForOverview"),
Future<void> _pushAndRemoveUntil(Widget screen) async { ),
await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => screen),
(route) => route.isFirst,
); );
} }
void _pushAndRemoveUntil(Widget screen) {
Navigator.of(context)
.popUntil((route) => route.settings.arguments != "popForOverview");
}
} }