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
f43a282f
Unverified
Commit
f43a282f
authored
Jun 10, 2021
by
xubaolin
Committed by
GitHub
Jun 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a DropdownButtonFormField label display issue (#83014)
parent
483f71ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+1
-1
dropdown_form_field_test.dart
packages/flutter/test/material/dropdown_form_field_test.dart
+54
-0
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
f43a282f
...
@@ -1622,7 +1622,7 @@ class DropdownButtonFormField<T> extends FormField<T> {
...
@@ -1622,7 +1622,7 @@ class DropdownButtonFormField<T> extends FormField<T> {
child:
Builder
(
builder:
(
BuildContext
context
)
{
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
InputDecorator
(
return
InputDecorator
(
decoration:
effectiveDecoration
.
copyWith
(
errorText:
field
.
errorText
),
decoration:
effectiveDecoration
.
copyWith
(
errorText:
field
.
errorText
),
isEmpty:
state
.
value
==
null
,
isEmpty:
items
==
null
||
items
.
where
((
DropdownMenuItem
<
T
>
item
)
=>
item
.
value
==
state
.
value
).
isEmpty
,
isFocused:
Focus
.
of
(
context
).
hasFocus
,
isFocused:
Focus
.
of
(
context
).
hasFocus
,
child:
DropdownButtonHideUnderline
(
child:
DropdownButtonHideUnderline
(
child:
DropdownButton
<
T
>(
child:
DropdownButton
<
T
>(
...
...
packages/flutter/test/material/dropdown_form_field_test.dart
View file @
f43a282f
...
@@ -149,6 +149,60 @@ void verifyPaintedShadow(Finder customPaint, int elevation) {
...
@@ -149,6 +149,60 @@ void verifyPaintedShadow(Finder customPaint, int elevation) {
}
}
void
main
(
)
{
void
main
(
)
{
// Regression test for https://github.com/flutter/flutter/issues/82910
testWidgets
(
'null value test'
,
(
WidgetTester
tester
)
async
{
int
?
value
=
1
;
await
tester
.
pumpWidget
(
TestApp
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
DropdownButtonFormField
<
int
?>(
decoration:
const
InputDecoration
(
labelText:
'labelText'
,
),
value:
value
,
onChanged:
(
int
?
newValue
)
{
value
=
newValue
;
},
items:
const
<
DropdownMenuItem
<
int
?>>[
DropdownMenuItem
<
int
?>(
value:
null
,
child:
Text
(
'None'
),
),
DropdownMenuItem
<
int
?>(
value:
1
,
child:
Text
(
'One'
),
),
DropdownMenuItem
<
int
?>(
value:
2
,
child:
Text
(
'Two'
),
),
DropdownMenuItem
<
int
?>(
value:
3
,
child:
Text
(
'Three'
),
)
],
),
),
),
);
expect
(
value
,
1
);
final
Offset
nonEmptyLabel
=
tester
.
getTopLeft
(
find
.
text
(
'labelText'
));
// Switch to `null` value item from value 1.
await
tester
.
tap
(
find
.
text
(
'One'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'None'
).
last
);
await
tester
.
pump
();
expect
(
value
,
null
);
final
Offset
nullValueLabel
=
tester
.
getTopLeft
(
find
.
text
(
'labelText'
));
// The position of the label does not change.
expect
(
nonEmptyLabel
,
nullValueLabel
);
});
testWidgets
(
'DropdownButtonFormField with autovalidation test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'DropdownButtonFormField with autovalidation test'
,
(
WidgetTester
tester
)
async
{
String
?
value
=
'one'
;
String
?
value
=
'one'
;
int
_validateCalled
=
0
;
int
_validateCalled
=
0
;
...
...
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