Skip to content

Commit

Permalink
replace dynamic by Object/Object? in router.dart (#80476)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminedakhlii committed Apr 17, 2021
1 parent aa7ab10 commit aa9f6a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/flutter/lib/src/widgets/router.dart
Expand Up @@ -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) {
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit aa9f6a2

Please sign in to comment.