$tryGetRouteParam<U> method
U
$tryGetRouteParam<
U>( - String key,
- U defaultValue
)
inherited
Implementation
@protected
@nonVirtual
@internal
U $tryGetRouteParam<U>(String key, U defaultValue) {
if (this.widget.$hasWidgetWrapper()) {
return this.widget.$getRouteParamFromWidgetWrapper(key);
}
ModalRoute? modelRoute = ModalRoute.of(this.context);
if (modelRoute == null) {
throw "Cannot access ModalRoute.of(this.context) in ${this} for key [${key}]";
}
Object? args = modelRoute.settings.arguments;
if (args == null || args is! Map<String, dynamic>) {
return defaultValue;
}
Map<String, dynamic> map = args;
if (!map.containsKey(key)) {
return defaultValue;
}
return map[key] as U;
}