I'm trying to create a Navigation RouteFuction which will navigate between screens, and i found this kind of error in RouterFcatory function. Code is below. thanks

RouteFactory _routes() {
    return (settings) {
      final Map<String, dynamic> arguments = settings.arguments;
      Widget screen;
      switch (settings.name) {
        case LocationsRoute:`
          screen = Locations();
          break;
        case LocationDetailRout:
        screen = LocationDetail(arguments['id']);
      }
    };
  }


Solution 1: Ujjwal Raijada

change

final Map<String, dynamic> arguments = settings.arguments;

to

final arguments = settings.arguments as Map<String, dynamic>;