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
f37a91a7
Unverified
Commit
f37a91a7
authored
Apr 25, 2020
by
Leonardo Emili
Committed by
GitHub
Apr 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add searchFieldStyle (#54674)
parent
cf0fcd45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
search.dart
packages/flutter/lib/src/material/search.dart
+9
-2
search_test.dart
packages/flutter/test/material/search_test.dart
+19
-1
No files found.
packages/flutter/lib/src/material/search.dart
View file @
f37a91a7
...
...
@@ -119,6 +119,7 @@ abstract class SearchDelegate<T> {
/// {@end-tool}
SearchDelegate
({
this
.
searchFieldLabel
,
this
.
searchFieldStyle
,
this
.
keyboardType
,
this
.
textInputAction
=
TextInputAction
.
search
,
});
...
...
@@ -264,6 +265,11 @@ abstract class SearchDelegate<T> {
/// If this value is set to null, the value of MaterialLocalizations.of(context).searchFieldLabel will be used instead.
final
String
searchFieldLabel
;
/// The style of the [searchFieldLabel].
///
/// If this value is set to null, the value of the ambient [Theme]'s [ThemeData.inputDecorationTheme.hintStyle] will be used instead.
final
TextStyle
searchFieldStyle
;
/// The type of action button to use for the keyboard.
///
/// Defaults to the default value specified in [TextField].
...
...
@@ -315,7 +321,6 @@ enum _SearchBody {
results
,
}
class
_SearchPageRoute
<
T
>
extends
PageRoute
<
T
>
{
_SearchPageRoute
({
@required
this
.
delegate
,
...
...
@@ -469,6 +474,8 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
final
ThemeData
theme
=
widget
.
delegate
.
appBarTheme
(
context
);
final
String
searchFieldLabel
=
widget
.
delegate
.
searchFieldLabel
??
MaterialLocalizations
.
of
(
context
).
searchFieldLabel
;
final
TextStyle
searchFieldStyle
=
widget
.
delegate
.
searchFieldStyle
??
theme
.
inputDecorationTheme
.
hintStyle
;
Widget
body
;
switch
(
widget
.
delegate
.
_currentBody
)
{
case
_SearchBody
.
suggestions
:
...
...
@@ -521,7 +528,7 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
hintText:
searchFieldLabel
,
hintStyle:
theme
.
inputDecorationTheme
.
hint
Style
,
hintStyle:
searchField
Style
,
),
),
actions:
widget
.
delegate
.
buildActions
(
context
),
...
...
packages/flutter/test/material/search_test.dart
View file @
f37a91a7
...
...
@@ -509,6 +509,23 @@ void main() {
expect
(
find
.
text
(
searchHint
),
findsOneWidget
);
});
testWidgets
(
'Custom searchFieldStyle value'
,
(
WidgetTester
tester
)
async
{
const
TextStyle
searchStyle
=
TextStyle
(
color:
Colors
.
red
,
fontSize:
3
);
final
_TestSearchDelegate
delegate
=
_TestSearchDelegate
(
searchFieldStyle:
searchStyle
);
await
tester
.
pumpWidget
(
TestHomePage
(
delegate:
delegate
,
));
await
tester
.
tap
(
find
.
byTooltip
(
'Search'
));
await
tester
.
pumpAndSettle
();
final
TextField
textField
=
tester
.
widget
<
TextField
>(
find
.
byType
(
TextField
));
final
TextStyle
hintStyle
=
textField
.
decoration
.
hintStyle
;
expect
(
hintStyle
,
delegate
.
searchFieldStyle
);
});
testWidgets
(
'keyboard show search button by default'
,
(
WidgetTester
tester
)
async
{
final
_TestSearchDelegate
delegate
=
_TestSearchDelegate
();
...
...
@@ -697,9 +714,10 @@ class _TestSearchDelegate extends SearchDelegate<String> {
this
.
suggestions
=
'Suggestions'
,
this
.
result
=
'Result'
,
this
.
actions
=
const
<
Widget
>[],
TextStyle
searchFieldStyle
,
String
searchHint
,
TextInputAction
textInputAction
=
TextInputAction
.
search
,
})
:
super
(
searchFieldLabel:
searchHint
,
textInputAction:
textInputAction
);
})
:
super
(
searchFieldLabel:
searchHint
,
textInputAction:
textInputAction
,
searchFieldStyle:
searchFieldStyle
);
final
String
suggestions
;
final
String
result
;
...
...
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