fix(app): restore standard Android back navigation
This commit is contained in:
@@ -51,12 +51,13 @@ class DetailPageHost {
|
||||
// Pushing during a build is not allowed; the page follows this frame.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!context.mounted || _route != route) return;
|
||||
Navigator.of(context).push(route).then((_) {
|
||||
Navigator.of(context).push(route);
|
||||
route.completed.then((_) {
|
||||
if (_route != route) return;
|
||||
_route = null;
|
||||
// Rebuild what lies underneath (route, tab bar, list) once the
|
||||
// page has finished sliding away, not during its animation.
|
||||
_afterExit(route, onClosed);
|
||||
// Keep ownership until the route is actually gone. Live updates
|
||||
// during its exit must not push a second copy of the detail page.
|
||||
onClosed();
|
||||
});
|
||||
});
|
||||
} else if (!selected && _route != null) {
|
||||
@@ -68,21 +69,6 @@ class DetailPageHost {
|
||||
}
|
||||
}
|
||||
|
||||
static void _afterExit(Route<void> route, VoidCallback onClosed) {
|
||||
final animation = route is ModalRoute<void> ? route.animation : null;
|
||||
if (animation == null || animation.status == AnimationStatus.dismissed) {
|
||||
onClosed();
|
||||
return;
|
||||
}
|
||||
late final AnimationStatusListener listener;
|
||||
listener = (status) {
|
||||
if (status != AnimationStatus.dismissed) return;
|
||||
animation.removeStatusListener(listener);
|
||||
onClosed();
|
||||
};
|
||||
animation.addStatusListener(listener);
|
||||
}
|
||||
|
||||
/// Removes the page with its owner.
|
||||
void dispose() {
|
||||
// The notifier is left to the page: a page still animating out keeps
|
||||
@@ -95,7 +81,7 @@ class DetailPageHost {
|
||||
|
||||
/// A full-screen page whose bar shows what the page's content publishes
|
||||
/// through [ShellBar] (title and actions), with the platform's Back.
|
||||
Route<void> detailPageRoute(
|
||||
PageRoute<void> detailPageRoute(
|
||||
BuildContext context, {
|
||||
required AppDestination destination,
|
||||
required WidgetBuilder builder,
|
||||
|
||||
Reference in New Issue
Block a user