mxGo method
void
mxGo(
- WidgetBuilder wb, {
- String path = '',
- String backPath = '/',
- OnMxResult? onResult,
- bool replace = false,
- bool exclude = false,
Implementation
void mxGo(WidgetBuilder wb,
{String path = '',
String backPath = '/',
OnMxResult? onResult,
bool replace = false,
bool exclude = false}) {
if (this == null) return;
final Map<String, WidgetBuilder> routeMap = {
"home": (BuildContext context) {
return Text('Home');
},
};
final builder = routeMap.containsKey(path)
? routeMap[path]
: wb != null
? wb
: routeMap['Home'];
var goRoute = path.isEmpty
? UIData.isIOS()
? MyPageRouteThree(builder!, routeName: path)
: MyPageRouteTwo(builder, routeName: path)
: UIData.isIOS()
? MyPageRouteThree(builder!, routeName: path)
: MyPageRouteTwo(builder, routeName: path);
if (exclude) {
var currentPath = ModalRoute.of(this!)?.settings.name;
if (currentPath == path) return;
Navigator.of(this!, rootNavigator: false).pushAndRemoveUntil(goRoute,
(route) {
return '/' == route.settings.name ||
backPath == route.settings.name ||
path == route.settings.name;
}).then((value) {
if (onResult != null) {
onResult(value);
}
});
return;
}
if (replace) {
Navigator.of(this!, rootNavigator: false)
.pushReplacement(goRoute)
.then((value) {
if (onResult != null) {
onResult(value);
}
});
return;
}
Navigator.of(this!, rootNavigator: false).push(goRoute).then((value) {
if (onResult != null) {
onResult(value);
}
});
}