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
328b292b
Unverified
Commit
328b292b
authored
Jun 18, 2021
by
Angjie Li
Committed by
GitHub
Jun 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add optional param to useRootNavigator when showSearch (#84581)" (#84827)
This reverts commit
a65328b4
.
parent
03034e9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
82 deletions
+1
-82
search.dart
packages/flutter/lib/src/material/search.dart
+1
-9
search_test.dart
packages/flutter/test/material/search_test.dart
+0
-73
No files found.
packages/flutter/lib/src/material/search.dart
View file @
328b292b
...
...
@@ -35,12 +35,6 @@ import 'theme.dart';
/// call. Call [SearchDelegate.close] before re-using the same delegate instance
/// for another [showSearch] call.
///
/// The `useRootNavigator` argument is used to determine whether to push the
/// search page to the [Navigator] furthest from or nearest to the given
/// `context`. By default, `useRootNavigator` is `true` and the search page
/// route created by this method is pushed to the furthest navigator to the
/// given `context`. It can not be `null`.
///
/// The transition to the search page triggered by this method looks best if the
/// screen triggering the transition contains an [AppBar] at the top and the
/// transition is called from an [IconButton] that's part of [AppBar.actions].
...
...
@@ -60,14 +54,12 @@ Future<T?> showSearch<T>({
required
BuildContext
context
,
required
SearchDelegate
<
T
>
delegate
,
String
?
query
=
''
,
bool
useRootNavigator
=
true
,
})
{
assert
(
delegate
!=
null
);
assert
(
context
!=
null
);
assert
(
useRootNavigator
!=
null
);
delegate
.
query
=
query
??
delegate
.
query
;
delegate
.
_currentBody
=
_SearchBody
.
suggestions
;
return
Navigator
.
of
(
context
,
rootNavigator:
useRootNavigator
).
push
(
_SearchPageRoute
<
T
>(
return
Navigator
.
of
(
context
).
push
(
_SearchPageRoute
<
T
>(
delegate:
delegate
,
));
}
...
...
packages/flutter/test/material/search_test.dart
View file @
328b292b
...
...
@@ -841,66 +841,6 @@ void main() {
expect
(
find
.
text
(
'Suggestions'
),
findsNothing
);
expect
(
selectedResults
,
<
String
>[
'Result'
]);
});
testWidgets
(
'showSearch with useRootNavigator'
,
(
WidgetTester
tester
)
async
{
final
MyNavigatorObserver
rootObserver
=
MyNavigatorObserver
();
final
MyNavigatorObserver
localObserver
=
MyNavigatorObserver
();
final
_TestEmptySearchDelegate
delegate
=
_TestEmptySearchDelegate
(
result:
'Result'
,
suggestions:
'Suggestions'
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
navigatorObservers:
<
NavigatorObserver
>[
rootObserver
],
home:
Navigator
(
observers:
<
NavigatorObserver
>[
localObserver
],
onGenerateRoute:
(
RouteSettings
settings
)
{
if
(
settings
.
name
==
'nested'
)
{
return
MaterialPageRoute
<
dynamic
>(
builder:
(
BuildContext
context
)
=>
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
TextButton
(
onPressed:
()
async
{
await
showSearch
(
context:
context
,
delegate:
delegate
);
},
child:
const
Text
(
'showSearchRootNavigator'
)),
TextButton
(
onPressed:
()
async
{
await
showSearch
(
context:
context
,
delegate:
delegate
,
useRootNavigator:
false
);
},
child:
const
Text
(
'showSearchLocalNavigator'
)),
],
),
settings:
settings
,
);
}
throw
UnimplementedError
();
},
initialRoute:
'nested'
,
),
));
expect
(
rootObserver
.
pushCount
,
0
);
expect
(
localObserver
.
pushCount
,
0
);
// showSearch normal and back
await
tester
.
tap
(
find
.
text
(
'showSearchLocalNavigator'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
byTooltip
(
'Close'
));
await
tester
.
pumpAndSettle
();
expect
(
rootObserver
.
pushCount
,
0
);
expect
(
localObserver
.
pushCount
,
1
);
// showSearch with rootNavigator
await
tester
.
tap
(
find
.
text
(
'showSearchRootNavigator'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
byTooltip
(
'Close'
));
await
tester
.
pumpAndSettle
();
expect
(
rootObserver
.
pushCount
,
1
);
expect
(
localObserver
.
pushCount
,
1
);
});
}
class
TestHomePage
extends
StatelessWidget
{
...
...
@@ -1086,16 +1026,3 @@ class _TestEmptySearchDelegate extends SearchDelegate<String> {
);
}
}
class
MyNavigatorObserver
extends
NavigatorObserver
{
int
pushCount
=
0
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>?
previousRoute
)
{
// don't count the root route
if
(<
String
>[
'nested'
,
'/'
].
contains
(
route
.
settings
.
name
))
{
return
;
}
pushCount
++;
}
}
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