Remove canTransitionFrom override from Material/CupertinoPageRoute (#45750)
This commit is contained in:
parent
8a9897c84c
commit
9d574d2c22
@ -176,11 +176,6 @@ class CupertinoPageRoute<T> extends PageRoute<T> {
|
|||||||
@override
|
@override
|
||||||
String get barrierLabel => null;
|
String get barrierLabel => null;
|
||||||
|
|
||||||
@override
|
|
||||||
bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) {
|
|
||||||
return previousRoute is CupertinoPageRoute;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) {
|
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) {
|
||||||
// Don't perform outgoing animation if the next route is a fullscreen dialog.
|
// Don't perform outgoing animation if the next route is a fullscreen dialog.
|
||||||
|
@ -66,11 +66,6 @@ class MaterialPageRoute<T> extends PageRoute<T> {
|
|||||||
@override
|
@override
|
||||||
String get barrierLabel => null;
|
String get barrierLabel => null;
|
||||||
|
|
||||||
@override
|
|
||||||
bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) {
|
|
||||||
return previousRoute is MaterialPageRoute || previousRoute is CupertinoPageRoute;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) {
|
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) {
|
||||||
// Don't perform outgoing animation if the next route is a fullscreen dialog.
|
// Don't perform outgoing animation if the next route is a fullscreen dialog.
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/cupertino.dart' show CupertinoPageRoute;
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -785,4 +786,32 @@ void main() {
|
|||||||
expect(homeTapCount, 2);
|
expect(homeTapCount, 2);
|
||||||
expect(pageTapCount, 1);
|
expect(pageTapCount, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('On iOS, a MaterialPageRoute should slide out with CupertinoPageTransition when a compatible PageRoute is pushed on top of it', (WidgetTester tester) async {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/44864.
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||||
|
home: Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Title')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Offset titleInitialTopLeft = tester.getTopLeft(find.text('Title'));
|
||||||
|
|
||||||
|
tester.state<NavigatorState>(find.byType(Navigator)).push<void>(
|
||||||
|
CupertinoPageRoute<void>(builder: (BuildContext context) => const Placeholder()),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(milliseconds: 150));
|
||||||
|
|
||||||
|
final Offset titleTransientTopLeft = tester.getTopLeft(find.text('Title'));
|
||||||
|
|
||||||
|
// Title of the first route slides to the left.
|
||||||
|
expect(titleInitialTopLeft.dy, equals(titleTransientTopLeft.dy));
|
||||||
|
expect(titleInitialTopLeft.dx, greaterThan(titleTransientTopLeft.dx));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user