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
567d0045
Unverified
Commit
567d0045
authored
Nov 21, 2022
by
chunhtai
Committed by
GitHub
Nov 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clip option for navigator (#115775)
parent
7045a8b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+11
-1
navigator_test.dart
packages/flutter/test/widgets/navigator_test.dart
+33
-0
No files found.
packages/flutter/lib/src/widgets/navigator.dart
View file @
567d0045
...
...
@@ -1385,7 +1385,7 @@ class Navigator extends StatefulWidget {
/// Creates a widget that maintains a stack-based history of child widgets.
///
/// The [onGenerateRoute], [pages], [onGenerateInitialRoutes],
/// [transitionDelegate], [observers]
arguments must not be null.
/// [transitionDelegate], [observers] arguments must not be null.
///
/// If the [pages] is not empty, the [onPopPage] must not be null.
const
Navigator
({
...
...
@@ -1398,6 +1398,7 @@ class Navigator extends StatefulWidget {
this
.
onUnknownRoute
,
this
.
transitionDelegate
=
const
DefaultTransitionDelegate
<
dynamic
>(),
this
.
reportsRouteUpdateToEngine
=
false
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
this
.
observers
=
const
<
NavigatorObserver
>[],
this
.
requestFocus
=
true
,
this
.
restorationScopeId
,
...
...
@@ -1563,6 +1564,14 @@ class Navigator extends StatefulWidget {
/// Defaults to false.
final
bool
reportsRouteUpdateToEngine
;
/// {@macro flutter.material.Material.clipBehavior}
///
/// In cases where clipping is not desired, consider setting this property to
/// [Clip.none].
///
/// Defaults to [Clip.hardEdge], and must not be null.
final
Clip
clipBehavior
;
/// Whether or not the navigator and it's new topmost route should request focus
/// when the new route is pushed onto the navigator.
///
...
...
@@ -5253,6 +5262,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
bucket:
bucket
,
child:
Overlay
(
key:
_overlayKey
,
clipBehavior:
widget
.
clipBehavior
,
initialEntries:
overlay
==
null
?
_allRouteOverlayEntries
.
toList
(
growable:
false
)
:
const
<
OverlayEntry
>[],
),
),
...
...
packages/flutter/test/widgets/navigator_test.dart
View file @
567d0045
...
...
@@ -200,6 +200,39 @@ void main() {
expect
(
find
.
text
(
'home'
),
findsOneWidget
);
});
testWidgets
(
'Navigator can set clip behavior'
,
(
WidgetTester
tester
)
async
{
const
MaterialPage
<
void
>
page
=
MaterialPage
<
void
>(
child:
Text
(
'page'
));
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Navigator
(
pages:
const
<
Page
<
void
>>[
page
],
onPopPage:
(
_
,
__
)
=>
false
,
),
),
),
);
// Default to hard edge.
expect
(
tester
.
widget
<
Overlay
>(
find
.
byType
(
Overlay
)).
clipBehavior
,
Clip
.
hardEdge
);
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Navigator
(
pages:
const
<
Page
<
void
>>[
page
],
clipBehavior:
Clip
.
none
,
onPopPage:
(
_
,
__
)
=>
false
,
),
),
),
);
expect
(
tester
.
widget
<
Overlay
>(
find
.
byType
(
Overlay
)).
clipBehavior
,
Clip
.
none
);
});
testWidgets
(
'Zero transition page-based route correctly notifies observers when it is popped'
,
(
WidgetTester
tester
)
async
{
final
List
<
Page
<
void
>>
pages
=
<
Page
<
void
>>[
const
ZeroTransitionPage
(
name:
'Page 1'
),
...
...
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