onGenerateAppRoute function Null safety

Route onGenerateAppRoute(
  1. RouteSettings settings
)

To use when custom route generation is needed, like when a screen needs some parameters

Implementation

Route onGenerateAppRoute(RouteSettings settings) {
  var route = settings.name;
  if (route==ROUTES.ParkingDetails) {
    RouteArgs<String> args = settings.arguments as RouteArgs<String>;
    return MaterialPageRoute(
      builder: (context) {
        return AuthGuard(context, ParkingDetailScreen(
          parkingId: args.value,
        ));
      },
    );
  } else if (route==ROUTES.Payment) {
    RouteArgs<Parking> args = settings.arguments as RouteArgs<Parking>;
    return MaterialPageRoute(
      builder: (context) {
        return AuthGuard(context,PaymentScreen(
          parking: args.value,
        ));
      },
    );
  } else {
    return MaterialPageRoute(
      builder: (context) {
        return AuthGuard(context, Home());
      },
    );
  }
}