replace dynamic by Object/Object? in router.dart (#80476)
This commit is contained in:
parent
aa7ab10822
commit
aa9f6a2a05
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user