navigatorPush static method

Future navigatorPush(
  1. BuildContext context,
  2. Widget widget,
  3. String name, {
  4. bool add = false,
  5. bool replace = false,
  6. bool fullscreenDialog = false,
  7. bool match = false,
  8. Offset? center,
})

公共打开方式

Implementation

static Future navigatorPush(BuildContext context, Widget widget, String name,
    {bool add = false,
    bool replace = false,
    bool fullscreenDialog = false,
    bool match = false,
    Offset? center}) {
  FocusScope.of(context).unfocus();
  var route = match
      ? CirclePageRoute(
          fullscreenDialog: fullscreenDialog,
          settings: RouteSettings(name: name),
          center: center,
          builder: (context) => widget)
      : CupertinoPageRoute(
          fullscreenDialog: fullscreenDialog,
          settings: RouteSettings(name: name),
          builder: (context) => widget);
  if (add) {
    if (routeMap[name]?.isActive == true) {
      Navigator.removeRoute(context, routeMap[name]);
    }
    routeMap[name] = route;
  }
  if (replace) {
    return Navigator.pushReplacement(context, route);
  } else {
    return Navigator.push(context, route);
  }
}