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
a9b8796a
Commit
a9b8796a
authored
Nov 01, 2018
by
Stefano Rodriguez
Committed by
Dan Field
Nov 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use maybePop in place of pop in ModalBarrier dismiss interaction (#22023)
* Use maybePop in place of pop in ModalBarrier
parent
720181cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
1 deletion
+81
-1
modal_barrier.dart
packages/flutter/lib/src/widgets/modal_barrier.dart
+1
-1
modal_barrier_test.dart
packages/flutter/test/widgets/modal_barrier_test.dart
+80
-0
No files found.
packages/flutter/lib/src/widgets/modal_barrier.dart
View file @
a9b8796a
...
...
@@ -83,7 +83,7 @@ class ModalBarrier extends StatelessWidget {
child:
GestureDetector
(
onTapDown:
(
TapDownDetails
details
)
{
if
(
dismissible
)
Navigator
.
p
op
(
context
);
Navigator
.
maybeP
op
(
context
);
},
behavior:
HitTestBehavior
.
opaque
,
child:
Semantics
(
...
...
packages/flutter/test/widgets/modal_barrier_test.dart
View file @
a9b8796a
...
...
@@ -85,6 +85,86 @@ void main() {
reason:
'The route should have been dismissed by tapping the barrier.'
);
});
testWidgets
(
'ModalBarrier does not pop the Navigator with a WillPopScope that returns false'
,
(
WidgetTester
tester
)
async
{
bool
willPopCalled
=
false
;
final
Map
<
String
,
WidgetBuilder
>
routes
=
<
String
,
WidgetBuilder
>{
'/'
:
(
BuildContext
context
)
=>
FirstWidget
(),
'/modal'
:
(
BuildContext
context
)
=>
Stack
(
children:
<
Widget
>[
SecondWidget
(),
WillPopScope
(
child:
const
SizedBox
(),
onWillPop:
()
async
{
willPopCalled
=
true
;
return
false
;
},
),
],),
};
await
tester
.
pumpWidget
(
MaterialApp
(
routes:
routes
));
// Initially the barrier is not visible
expect
(
find
.
byKey
(
const
ValueKey
<
String
>(
'barrier'
)),
findsNothing
);
// Tapping on X routes to the barrier
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pump
();
// begin transition
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// end transition
expect
(
willPopCalled
,
isFalse
);
// Tap on the barrier to attempt to dismiss it
await
tester
.
tap
(
find
.
byKey
(
const
ValueKey
<
String
>(
'barrier'
)));
await
tester
.
pump
();
// begin transition
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// end transition
expect
(
find
.
byKey
(
const
ValueKey
<
String
>(
'barrier'
)),
findsOneWidget
,
reason:
'The route should still be present if the pop is vetoed.'
);
expect
(
willPopCalled
,
isTrue
);
});
testWidgets
(
'ModalBarrier pops the Navigator with a WillPopScope that returns true'
,
(
WidgetTester
tester
)
async
{
bool
willPopCalled
=
false
;
final
Map
<
String
,
WidgetBuilder
>
routes
=
<
String
,
WidgetBuilder
>{
'/'
:
(
BuildContext
context
)
=>
FirstWidget
(),
'/modal'
:
(
BuildContext
context
)
=>
Stack
(
children:
<
Widget
>[
SecondWidget
(),
WillPopScope
(
child:
const
SizedBox
(),
onWillPop:
()
async
{
willPopCalled
=
true
;
return
true
;
},
),
],),
};
await
tester
.
pumpWidget
(
MaterialApp
(
routes:
routes
));
// Initially the barrier is not visible
expect
(
find
.
byKey
(
const
ValueKey
<
String
>(
'barrier'
)),
findsNothing
);
// Tapping on X routes to the barrier
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pump
();
// begin transition
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// end transition
expect
(
willPopCalled
,
isFalse
);
// Tap on the barrier to attempt to dismiss it
await
tester
.
tap
(
find
.
byKey
(
const
ValueKey
<
String
>(
'barrier'
)));
await
tester
.
pump
();
// begin transition
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// end transition
expect
(
find
.
byKey
(
const
ValueKey
<
String
>(
'barrier'
)),
findsNothing
,
reason:
'The route should not be present if the pop is permitted.'
);
expect
(
willPopCalled
,
isTrue
);
});
testWidgets
(
'Undismissible ModalBarrier hidden in semantic tree'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
const
ModalBarrier
(
dismissible:
false
));
...
...
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