Unverified Commit aa9f6a2a authored by Amine Dakhli's avatar Amine Dakhli Committed by GitHub

replace dynamic by Object/Object? in router.dart (#80476)

parent aa7ab108
......@@ -306,7 +306,7 @@ class Router<T> extends StatefulWidget {
///
/// * [maybeOf], which is a similar function, but it will return null instead
/// of throwing an exception if no [Router] ancestor exists.
static Router<dynamic> of(BuildContext context) {
static Router<T> of<T extends Object?>(BuildContext context) {
final _RouterScope? scope = context.dependOnInheritedWidgetOfExactType<_RouterScope>();
assert(() {
if (scope == null) {
......@@ -318,7 +318,7 @@ class Router<T> extends StatefulWidget {
}
return true;
}());
return scope!.routerState.widget;
return scope!.routerState.widget as Router<T>;
}
/// Retrieves the immediate [Router] ancestor from the given context.
......@@ -334,9 +334,9 @@ class Router<T> extends StatefulWidget {
///
/// * [of], a similar method that returns a non-nullable value, and will
/// throw if no [Router] ancestor exists.
static Router<dynamic>? maybeOf(BuildContext context) {
static Router<T>? maybeOf<T extends Object?>(BuildContext context) {
final _RouterScope? scope = context.dependOnInheritedWidgetOfExactType<_RouterScope>();
return scope?.routerState.widget;
return scope?.routerState.widget as Router<T>?;
}
/// Forces the [Router] to run the [callback] and reports the route
......@@ -704,9 +704,9 @@ class _RouterScope extends InheritedWidget {
final ValueListenable<RouteInformation?>? routeInformationProvider;
final BackButtonDispatcher? backButtonDispatcher;
final RouteInformationParser<dynamic>? routeInformationParser;
final RouterDelegate<dynamic> routerDelegate;
final _RouterState<dynamic> routerState;
final RouteInformationParser<Object?>? routeInformationParser;
final RouterDelegate<Object?> routerDelegate;
final _RouterState<Object?> routerState;
@override
bool updateShouldNotify(_RouterScope oldWidget) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment