Unverified Commit 77504823 authored by Ren You's avatar Ren You Committed by GitHub

Revert "Replace some `dynamic` to `Object?` type (#80772)" (#80965)

This reverts commit 12a2e682.
parent 523c812b
......@@ -789,7 +789,7 @@ class _AppBarState extends State<AppBar> {
final ColorScheme colorScheme = theme.colorScheme;
final AppBarTheme appBarTheme = AppBarTheme.of(context);
final ScaffoldState? scaffold = Scaffold.maybeOf(context);
final ModalRoute<Object?>? parentRoute = ModalRoute.of(context);
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
final FlexibleSpaceBarSettings? settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
final Set<MaterialState> states = <MaterialState>{
......@@ -799,7 +799,7 @@ class _AppBarState extends State<AppBar> {
final bool hasDrawer = scaffold?.hasDrawer ?? false;
final bool hasEndDrawer = scaffold?.hasEndDrawer ?? false;
final bool canPop = parentRoute?.canPop ?? false;
final bool useCloseButton = parentRoute is PageRoute<Object?> && parentRoute.fullscreenDialog;
final bool useCloseButton = parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
final double toolbarHeight = widget.toolbarHeight ?? appBarTheme.toolbarHeight ?? kToolbarHeight;
final bool backwardsCompatibility = widget.backwardsCompatibility ?? appBarTheme.backwardsCompatibility ?? true;
......
......@@ -363,7 +363,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
void _ensureHistoryEntry() {
if (_historyEntry == null) {
final ModalRoute<Object?>? route = ModalRoute.of(context);
final ModalRoute<dynamic>? route = ModalRoute.of(context);
if (route != null) {
_historyEntry = LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved);
route.addLocalHistoryEntry(_historyEntry!);
......
......@@ -452,7 +452,7 @@ class ScaffoldMessengerState extends State<ScaffoldMessenger> with TickerProvide
_accessibleNavigation = mediaQuery.accessibleNavigation;
if (_snackBars.isNotEmpty) {
final ModalRoute<Object?>? route = ModalRoute.of(context);
final ModalRoute<dynamic>? route = ModalRoute.of(context);
if (route == null || route.isCurrent) {
if (_snackBarController!.isCompleted && _snackBarTimer == null) {
final SnackBar snackBar = _snackBars.first._widget;
......@@ -2408,7 +2408,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
// Important if the app/user takes an action that could repeatedly show a
// bottom sheet.
final List<_StandardBottomSheet> _dismissedBottomSheets = <_StandardBottomSheet>[];
PersistentBottomSheetController<Object?>? _currentBottomSheet;
PersistentBottomSheetController<dynamic>? _currentBottomSheet;
final GlobalKey _currentBottomSheetKey = GlobalKey();
void _maybeBuildPersistentBottomSheet() {
......@@ -2985,7 +2985,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
// TODO(Piinks): Remove old SnackBar API after migrating ScaffoldMessenger
_accessibleNavigation = mediaQuery.accessibleNavigation;
if (_snackBars.isNotEmpty) {
final ModalRoute<Object?>? route = ModalRoute.of(context);
final ModalRoute<dynamic>? route = ModalRoute.of(context);
if (route == null || route.isCurrent) {
if (_snackBarController!.isCompleted && _snackBarTimer == null) {
final SnackBar snackBar = _snackBars.first._widget;
......
......@@ -487,8 +487,8 @@ class _HeroFlightManifest {
final HeroFlightDirection type;
final OverlayState overlay;
final Size navigatorSize;
final PageRoute<Object?> fromRoute;
final PageRoute<Object?> toRoute;
final PageRoute<dynamic> fromRoute;
final PageRoute<dynamic> toRoute;
final _HeroState fromHero;
final _HeroState toHero;
final CreateRectTween? createRectTween;
......@@ -830,14 +830,14 @@ class HeroController extends NavigatorObserver {
final Map<Object, _HeroFlight> _flights = <Object, _HeroFlight>{};
@override
void didPush(Route<Object?> route, Route<Object?>? previousRoute) {
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
assert(navigator != null);
assert(route != null);
_maybeStartHeroTransition(previousRoute, route, HeroFlightDirection.push, false);
}
@override
void didPop(Route<Object?> route, Route<Object?>? previousRoute) {
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
assert(navigator != null);
assert(route != null);
// Don't trigger another flight when a pop is committed as a user gesture
......@@ -847,7 +847,7 @@ class HeroController extends NavigatorObserver {
}
@override
void didReplace({ Route<Object?>? newRoute, Route<Object?>? oldRoute }) {
void didReplace({ Route<dynamic>? newRoute, Route<dynamic>? oldRoute }) {
assert(navigator != null);
if (newRoute?.isCurrent == true) {
// Only run hero animations if the top-most route got replaced.
......@@ -856,7 +856,7 @@ class HeroController extends NavigatorObserver {
}
@override
void didStartUserGesture(Route<Object?> route, Route<Object?>? previousRoute) {
void didStartUserGesture(Route<dynamic> route, Route<dynamic>? previousRoute) {
assert(navigator != null);
assert(route != null);
_maybeStartHeroTransition(route, previousRoute, HeroFlightDirection.pop, true);
......@@ -892,14 +892,14 @@ class HeroController extends NavigatorObserver {
// If we're transitioning between different page routes, start a hero transition
// after the toRoute has been laid out with its animation's value at 1.0.
void _maybeStartHeroTransition(
Route<Object?>? fromRoute,
Route<Object?>? toRoute,
Route<dynamic>? fromRoute,
Route<dynamic>? toRoute,
HeroFlightDirection flightType,
bool isUserGestureTransition,
) {
if (toRoute != fromRoute && toRoute is PageRoute<Object?> && fromRoute is PageRoute<Object?>) {
final PageRoute<Object?> from = fromRoute;
final PageRoute<Object?> to = toRoute;
if (toRoute != fromRoute && toRoute is PageRoute<dynamic> && fromRoute is PageRoute<dynamic>) {
final PageRoute<dynamic> from = fromRoute;
final PageRoute<dynamic> to = toRoute;
final Animation<double> animation = (flightType == HeroFlightDirection.push) ? to.animation! : from.animation!;
// A user gesture may have already completed the pop, or we might be the initial route
......@@ -940,8 +940,8 @@ class HeroController extends NavigatorObserver {
// Find the matching pairs of heroes in from and to and either start or a new
// hero flight, or divert an existing one.
void _startHeroTransition(
PageRoute<Object?> from,
PageRoute<Object?> to,
PageRoute<dynamic> from,
PageRoute<dynamic> to,
Animation<double> animation,
HeroFlightDirection flightType,
bool isUserGestureTransition,
......
......@@ -225,7 +225,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
}
@override
void didReplace(Route<Object?>? oldRoute) {
void didReplace(Route<dynamic>? oldRoute) {
assert(_controller != null, '$runtimeType.didReplace called before calling install() or after calling dispose().');
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
if (oldRoute is TransitionRoute)
......@@ -243,7 +243,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
}
@override
void didPopNext(Route<Object?> nextRoute) {
void didPopNext(Route<dynamic> nextRoute) {
assert(_controller != null, '$runtimeType.didPopNext called before calling install() or after calling dispose().');
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
_updateSecondaryAnimation(nextRoute);
......@@ -251,7 +251,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
}
@override
void didChangeNext(Route<Object?>? nextRoute) {
void didChangeNext(Route<dynamic>? nextRoute) {
assert(_controller != null, '$runtimeType.didChangeNext called before calling install() or after calling dispose().');
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
_updateSecondaryAnimation(nextRoute);
......@@ -265,14 +265,14 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
// caller must reset this property to null after it is called.
VoidCallback? _trainHoppingListenerRemover;
void _updateSecondaryAnimation(Route<Object?>? nextRoute) {
void _updateSecondaryAnimation(Route<dynamic>? nextRoute) {
// There is an existing train hopping in progress. Unfortunately, we cannot
// dispose current train hopping animation until we replace it with a new
// animation.
final VoidCallback? previousTrainHoppingListenerRemover = _trainHoppingListenerRemover;
_trainHoppingListenerRemover = null;
if (nextRoute is TransitionRoute<Object?> && canTransitionTo(nextRoute) && nextRoute.canTransitionFrom(this)) {
if (nextRoute is TransitionRoute<dynamic> && canTransitionTo(nextRoute) && nextRoute.canTransitionFrom(this)) {
final Animation<double>? current = _secondaryAnimation.parent;
if (current != null) {
final Animation<double> currentTrain = (current is TrainHoppingAnimation ? current.currentTrain : current)!;
......@@ -348,11 +348,11 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
}
}
void _setSecondaryAnimation(Animation<double>? animation, [Future<Object?>? disposed]) {
void _setSecondaryAnimation(Animation<double>? animation, [Future<dynamic>? disposed]) {
_secondaryAnimation.parent = animation;
// Releases the reference to the next route's animation when that route
// is disposed.
disposed?.then((Object? _) {
disposed?.then((dynamic _) {
if (_secondaryAnimation.parent == animation) {
_secondaryAnimation.parent = kAlwaysDismissedAnimation;
if (animation is TrainHoppingAnimation) {
......@@ -386,7 +386,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
///
/// * [canTransitionFrom], which must be true for [nextRoute] for the
/// [ModalRoute.buildTransitions] `secondaryAnimation` to run.
bool canTransitionTo(TransitionRoute<Object?> nextRoute) => true;
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) => true;
/// Returns true if [previousRoute] should animate when this route
/// is pushed on top of it or when then this route is popped off of it.
......@@ -411,7 +411,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
///
/// * [canTransitionTo], which must be true for [previousRoute] for its
/// [ModalRoute.buildTransitions] `secondaryAnimation` to run.
bool canTransitionFrom(TransitionRoute<Object?> previousRoute) => true;
bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) => true;
@override
void dispose() {
......@@ -437,7 +437,7 @@ class LocalHistoryEntry {
/// Called when this entry is removed from the history of its associated [LocalHistoryRoute].
final VoidCallback? onRemove;
LocalHistoryRoute<Object?>? _owner;
LocalHistoryRoute<dynamic>? _owner;
/// Remove this entry from the history of its associated [LocalHistoryRoute].
void remove() {
......@@ -660,7 +660,7 @@ class _DismissModalAction extends DismissAction {
@override
bool isEnabled(DismissIntent intent) {
final ModalRoute<Object?> route = ModalRoute.of<Object?>(context)!;
final ModalRoute<dynamic> route = ModalRoute.of<dynamic>(context)!;
return route.barrierDismissible;
}
......@@ -685,7 +685,7 @@ class _ModalScopeStatus extends InheritedWidget {
final bool isCurrent;
final bool canPop;
final Route<Object?> route;
final Route<dynamic> route;
@override
bool updateShouldNotify(_ModalScopeStatus old) {
......@@ -934,7 +934,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
///
/// This function is typically used with [Navigator.popUntil()].
static RoutePredicate withName(String name) {
return (Route<Object?> route) {
return (Route<dynamic> route) {
return !route.willHandlePopInternally
&& route is ModalRoute
&& route.settings.name == name;
......@@ -1391,7 +1391,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
/// [State.didChangeDependencies] callback:
///
/// ```dart
/// ModalRoute<Object?> _route;
/// ModalRoute<dynamic> _route;
///
/// @override
/// void didChangeDependencies() {
......@@ -1464,7 +1464,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
}
@override
void didChangePrevious(Route<Object?>? previousRoute) {
void didChangePrevious(Route<dynamic>? previousRoute) {
super.didChangePrevious(previousRoute);
changedInternalState();
}
......@@ -1613,9 +1613,9 @@ abstract class PopupRoute<T> extends ModalRoute<T> {
/// as `always_specify_types`, the Dart analyzer will require that certain types
/// be given with their type arguments. Since the [Route] class and its
/// subclasses have a type argument, this includes the arguments passed to this
/// class. Consider using `Object?` to specify the entire class of routes rather
/// class. Consider using `dynamic` to specify the entire class of routes rather
/// than only specific subtypes. For example, to watch for all [ModalRoute]
/// variants, the `RouteObserver<ModalRoute<Object?>>` type may be used.
/// variants, the `RouteObserver<ModalRoute<dynamic>>` type may be used.
///
/// {@tool snippet}
///
......@@ -1670,7 +1670,7 @@ abstract class PopupRoute<T> extends ModalRoute<T> {
/// }
/// ```
/// {@end-tool}
class RouteObserver<R extends Route<Object?>> extends NavigatorObserver {
class RouteObserver<R extends Route<dynamic>> extends NavigatorObserver {
final Map<R, Set<RouteAware>> _listeners = <R, Set<RouteAware>>{};
/// Subscribe [routeAware] to be informed about changes to [route].
......@@ -1700,7 +1700,7 @@ class RouteObserver<R extends Route<Object?>> extends NavigatorObserver {
}
@override
void didPop(Route<Object?> route, Route<Object?>? previousRoute) {
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (route is R && previousRoute is R) {
final List<RouteAware>? previousSubscribers = _listeners[previousRoute]?.toList();
......@@ -1721,7 +1721,7 @@ class RouteObserver<R extends Route<Object?>> extends NavigatorObserver {
}
@override
void didPush(Route<Object?> route, Route<Object?>? previousRoute) {
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (route is R && previousRoute is R) {
final Set<RouteAware>? previousSubscribers = _listeners[previousRoute];
......
......@@ -117,7 +117,7 @@ class WillPopScope extends StatefulWidget {
}
class _WillPopScopeState extends State<WillPopScope> {
ModalRoute<Object?>? _route;
ModalRoute<dynamic>? _route;
@override
void didChangeDependencies() {
......
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