pushReplacementNamed<T extends Object?, TO extends Object?> static method
push 到指定页面并替换当前页面
@param routeName 要跳转的页面 @param pageType PageType页面类型,默认PageType.flutter @param isOpaque 是否不透明 默认-true 不透明 @param animated 是否开启动画,默认开启 @return T 泛型,用于指定返回类型, 仅支持flutter -> flutter的场景
Implementation
static Future<T?> pushReplacementNamed<T extends Object?, TO extends Object?>(
String routeName, {
PageType pageType = PageType.flutter,
bool isOpaque = true,
bool animated = true,
Map<String, dynamic>? arguments,
}) async {
/// 当前引擎路由栈大于一个页面的时候直接在flutter端替换
final routeStack = navigatorObserver.routeNameStack;
if (routeStack.isNotEmpty && pageType == PageType.flutter) {
return await _flutterNavigator.pushReplacementNamed<T, TO>(
routeName,
isOpaque: isOpaque,
animated: animated,
arguments: arguments,
);
} else {
/// 当前引擎路由栈只有一个页面时调原生方法
return await _nativeNavigator.pushReplacementNamed<T, TO>(
routeName,
pageType: pageType,
isOpaque: isOpaque,
animated: animated,
arguments: arguments,
);
}
}