Reputation: 1
RouteFactory _routes() {
return (settings) {
final args = settings.arguments;
final Map<String, dynamic> arguments = **args** ; //here is error in args
Widget screen;
switch (settings.name) {
case LocationRoute:
screen = Locations();
break;
case LocationDetailRoute:
screen = LocationDetail(arguments['id']);
break;
default:
return null;
}
return MaterialPageRoute(builder: (BuildContext context) => screen);
};
}
here in args there is an error(A value of type 'Object?' can't be assigned to a variable of type 'Map<String, dynamic>'. Try changing the type of the variable, or casting the right-hand type to 'Map<String, dynamic>'.)
Upvotes: 0
Views: 1975
Reputation: 5736
Manually Cast args
as Map<String, dynamic>
.
final Map<String, dynamic> arguments = args as Map<String, dynamic>;
Upvotes: 1