Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b8df8a83
Unverified
Commit
b8df8a83
authored
Jul 23, 2020
by
Abdur Rafay Saleem
Committed by
GitHub
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowed specifying reverseTransitionDuration in PageRouteBuilder class (#61752)
parent
c816fabd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
0 deletions
+114
-0
pages.dart
packages/flutter/lib/src/widgets/pages.dart
+11
-0
routes_test.dart
packages/flutter/test/widgets/routes_test.dart
+103
-0
No files found.
packages/flutter/lib/src/widgets/pages.dart
View file @
b8df8a83
...
@@ -62,6 +62,7 @@ class PageRouteBuilder<T> extends PageRoute<T> {
...
@@ -62,6 +62,7 @@ class PageRouteBuilder<T> extends PageRoute<T> {
@required
this
.
pageBuilder
,
@required
this
.
pageBuilder
,
this
.
transitionsBuilder
=
_defaultTransitionsBuilder
,
this
.
transitionsBuilder
=
_defaultTransitionsBuilder
,
this
.
transitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
transitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
reverseTransitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
opaque
=
true
,
this
.
opaque
=
true
,
this
.
barrierDismissible
=
false
,
this
.
barrierDismissible
=
false
,
this
.
barrierColor
,
this
.
barrierColor
,
...
@@ -93,6 +94,9 @@ class PageRouteBuilder<T> extends PageRoute<T> {
...
@@ -93,6 +94,9 @@ class PageRouteBuilder<T> extends PageRoute<T> {
@override
@override
final
Duration
transitionDuration
;
final
Duration
transitionDuration
;
@override
final
Duration
reverseTransitionDuration
;
@override
@override
final
bool
opaque
;
final
bool
opaque
;
...
@@ -134,6 +138,7 @@ class TransitionBuilderPage<T> extends Page<T> {
...
@@ -134,6 +138,7 @@ class TransitionBuilderPage<T> extends Page<T> {
@required
this
.
pageBuilder
,
@required
this
.
pageBuilder
,
this
.
transitionsBuilder
=
_defaultTransitionsBuilder
,
this
.
transitionsBuilder
=
_defaultTransitionsBuilder
,
this
.
transitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
transitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
reverseTransitionDuration
=
const
Duration
(
milliseconds:
300
),
this
.
opaque
=
true
,
this
.
opaque
=
true
,
this
.
barrierDismissible
=
false
,
this
.
barrierDismissible
=
false
,
this
.
barrierColor
,
this
.
barrierColor
,
...
@@ -160,6 +165,9 @@ class TransitionBuilderPage<T> extends Page<T> {
...
@@ -160,6 +165,9 @@ class TransitionBuilderPage<T> extends Page<T> {
/// {@macro flutter.widgets.transitionRoute.transitionDuration}
/// {@macro flutter.widgets.transitionRoute.transitionDuration}
final
Duration
transitionDuration
;
final
Duration
transitionDuration
;
/// {@macro flutter.widgets.transitionRoute.reverseTransitionDuration}
final
Duration
reverseTransitionDuration
;
/// {@macro flutter.widgets.transitionRoute.opaque}
/// {@macro flutter.widgets.transitionRoute.opaque}
final
bool
opaque
;
final
bool
opaque
;
...
@@ -197,6 +205,9 @@ class _PageBasedPageRouteBuilder<T> extends PageRoute<T>{
...
@@ -197,6 +205,9 @@ class _PageBasedPageRouteBuilder<T> extends PageRoute<T>{
@override
@override
Duration
get
transitionDuration
=>
_page
.
transitionDuration
;
Duration
get
transitionDuration
=>
_page
.
transitionDuration
;
@override
Duration
get
reverseTransitionDuration
=>
_page
.
reverseTransitionDuration
;
@override
@override
bool
get
opaque
=>
_page
.
opaque
;
bool
get
opaque
=>
_page
.
opaque
;
...
...
packages/flutter/test/widgets/routes_test.dart
View file @
b8df8a83
...
@@ -674,6 +674,109 @@ void main() {
...
@@ -674,6 +674,109 @@ void main() {
expect
(
find
.
text
(
'second'
),
findsOneWidget
);
expect
(
find
.
text
(
'second'
),
findsOneWidget
);
});
});
group
(
'PageRouteBuilder'
,
()
{
testWidgets
(
'reverseTransitionDuration defaults to 300ms'
,
(
WidgetTester
tester
)
async
{
// Default PageRouteBuilder reverse transition duration should be 300ms.
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
<
dynamic
>(
builder:
(
BuildContext
context
)
{
return
RaisedButton
(
onPressed:
()
{
Navigator
.
of
(
context
).
push
<
void
>(
PageRouteBuilder
<
void
>(
settings:
settings
,
pageBuilder:
(
BuildContext
context
,
Animation
<
double
>
input
,
Animation
<
double
>
out
)
{
return
const
Text
(
'Page Two'
);
},
)
);
},
child:
const
Text
(
'Open page'
),
);
},
);
},
)
);
// Open the new route.
await
tester
.
tap
(
find
.
byType
(
RaisedButton
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Open page'
),
findsNothing
);
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Pop the new route.
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pop
();
await
tester
.
pump
();
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Text('Page Two') should be present halfway through the reverse transition.
await
tester
.
pump
(
const
Duration
(
milliseconds:
150
));
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Text('Page Two') should be present at the very end of the reverse transition.
await
tester
.
pump
(
const
Duration
(
milliseconds:
150
));
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Text('Page Two') have transitioned out after 300ms.
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
expect
(
find
.
text
(
'Page Two'
),
findsNothing
);
expect
(
find
.
text
(
'Open page'
),
findsOneWidget
);
});
testWidgets
(
'reverseTransitionDuration can be customized'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
<
dynamic
>(
builder:
(
BuildContext
context
)
{
return
RaisedButton
(
onPressed:
()
{
Navigator
.
of
(
context
).
push
<
void
>(
PageRouteBuilder
<
void
>(
settings:
settings
,
pageBuilder:
(
BuildContext
context
,
Animation
<
double
>
input
,
Animation
<
double
>
out
)
{
return
const
Text
(
'Page Two'
);
},
// modified value, default PageRouteBuilder reverse transition duration should be 300ms.
reverseTransitionDuration:
const
Duration
(
milliseconds:
150
),
)
);
},
child:
const
Text
(
'Open page'
),
);
},
);
})
);
// Open the new route.
await
tester
.
tap
(
find
.
byType
(
RaisedButton
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Open page'
),
findsNothing
);
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Pop the new route.
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pop
();
await
tester
.
pump
();
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Text('Page Two') should be present halfway through the reverse transition.
await
tester
.
pump
(
const
Duration
(
milliseconds:
75
));
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Text('Page Two') should be present at the very end of the reverse transition.
await
tester
.
pump
(
const
Duration
(
milliseconds:
75
));
expect
(
find
.
text
(
'Page Two'
),
findsOneWidget
);
// Text('Page Two') have transitioned out after 500ms.
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
expect
(
find
.
text
(
'Page Two'
),
findsNothing
);
expect
(
find
.
text
(
'Open page'
),
findsOneWidget
);
});
});
group
(
'TransitionRoute'
,
()
{
group
(
'TransitionRoute'
,
()
{
testWidgets
(
'secondary animation is kDismissed when next route finishes pop'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'secondary animation is kDismissed when next route finishes pop'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
NavigatorState
>
navigator
=
GlobalKey
<
NavigatorState
>();
final
GlobalKey
<
NavigatorState
>
navigator
=
GlobalKey
<
NavigatorState
>();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment