buildAnimatedPage method

  1. @override
Page buildAnimatedPage(
  1. BuildContext context
)
override

Built-in page types wrap their content so a root page keeps system back (Android predictive back). Custom subclasses that override this, including types returned from ReplaceAnimationTypeCustom.handler, do not get that wrap, and on Android 16 back on such a root closes the app.

Implementation

@override
Page<dynamic> buildAnimatedPage(BuildContext context) {
  if (!swipeToDismissEnabled && defaultTargetPlatform == TargetPlatform.iOS) {
    return NoSwipePage<dynamic>(
      key: key,
      name: screenName,
      child: RootPopScope(child: builder(context)),
    );
  }

  return super.buildAnimatedPage(context);
}