generate<T> method

Route<T> generate<T>(
  1. RouteSettings settings
)

Implementation

Route<T> generate<T>(RouteSettings settings) {
  var name = settings.name;
  var data = settings.arguments;
  var mRoutes = routes();
  var isValidRoute = mRoutes.isNotEmpty;

  var mConfig = config.adjust(data("__app_route_config__", config));
  var allowSnapshotting = mConfig.allowSnapshotting;
  var animationCurve = mConfig.animationCurve;
  var animationTime = mConfig.animationTime;
  var animationReserveTime = mConfig.animationReserveTime;
  var animationType = mConfig.animationType;
  var barrierColor = mConfig.barrierColor;
  var barrierDismissible = mConfig.barrierDismissible;
  var barrierLabel = mConfig.barrierLabel;
  var fullscreenDialog = mConfig.fullscreenDialog;
  var maintainState = mConfig.maintainState;
  var opaque = mConfig.opaque;

  if (isValidRoute) {
    var route = mRoutes[name];
    if (route != null) {
      return AppRoute<T>(
        name: name,
        allowSnapshotting: allowSnapshotting,
        animationTime: animationTime,
        animationReserveTime: animationReserveTime,
        animationType: animationType,
        arguments: data,
        barrierColor: barrierColor,
        barrierDismissible: barrierDismissible,
        barrierLabel: barrierLabel,
        animationCurve: animationCurve,
        fullscreenDialog: fullscreenDialog,
        maintainState: maintainState,
        opaque: opaque,
        builder: (_) => route(_, data),
      );
    } else {
      return AppRoute<T>(
        name: name,
        allowSnapshotting: allowSnapshotting,
        animationCurve: animationCurve,
        animationTime: animationTime,
        animationReserveTime: animationReserveTime,
        animationType: animationType,
        arguments: data,
        barrierColor: barrierColor,
        barrierDismissible: barrierDismissible,
        barrierLabel: barrierLabel,
        fullscreenDialog: fullscreenDialog,
        maintainState: maintainState,
        opaque: opaque,
        builder: (context) => onError(context, data),
      );
    }
  } else {
    return AppRoute<T>(
      name: name,
      allowSnapshotting: allowSnapshotting,
      animationTime: animationTime,
      animationReserveTime: animationReserveTime,
      animationType: animationType,
      arguments: data,
      barrierColor: barrierColor,
      barrierDismissible: barrierDismissible,
      barrierLabel: barrierLabel,
      animationCurve: animationCurve,
      fullscreenDialog: fullscreenDialog,
      maintainState: maintainState,
      opaque: opaque,
      builder: (context) => onDefault(context, data),
    );
  }
}