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
9f744a9e
Unverified
Commit
9f744a9e
authored
May 21, 2020
by
Justin McCandless
Committed by
GitHub
May 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow updating textAlignVertical (#57033)
parent
26fabcd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
6 deletions
+48
-6
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+9
-6
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+39
-0
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
9f744a9e
...
...
@@ -781,20 +781,22 @@ class _RenderDecoration extends RenderBox {
markNeedsLayout
();
}
TextAlignVertical
get
_defaultTextAlignVertical
=>
_isOutlineAligned
?
TextAlignVertical
.
center
:
TextAlignVertical
.
top
;
TextAlignVertical
get
textAlignVertical
{
if
(
_textAlignVertical
==
null
)
{
return
_
isOutlineAligned
?
TextAlignVertical
.
center
:
TextAlignVertical
.
top
;
return
_
defaultTextAlignVertical
;
}
return
_textAlignVertical
;
}
TextAlignVertical
_textAlignVertical
;
set
textAlignVertical
(
TextAlignVertical
value
)
{
assert
(
value
!=
null
);
if
(
_textAlignVertical
==
value
)
{
return
;
}
// No need to relayout if the effective value is still the same.
if
(
textAlignVertical
.
y
==
value
.
y
)
{
if
(
textAlignVertical
.
y
==
(
value
?.
y
??
_defaultTextAlignVertical
.
y
)
)
{
_textAlignVertical
=
value
;
return
;
}
...
...
@@ -1707,10 +1709,11 @@ class _Decorator extends RenderObjectWidget {
void
updateRenderObject
(
BuildContext
context
,
_RenderDecoration
renderObject
)
{
renderObject
..
decoration
=
decoration
..
textDirection
=
textDirection
..
textBaseline
=
textBaseline
..
expands
=
expands
..
isFocused
=
isFocused
;
..
isFocused
=
isFocused
..
textAlignVertical
=
textAlignVertical
..
textBaseline
=
textBaseline
..
textDirection
=
textDirection
;
}
}
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
9f744a9e
...
...
@@ -3997,4 +3997,43 @@ void main() {
// because the label is not initially floating.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'label'
)).
dy
,
20.0
);
});
testWidgets
(
'textAlignVertical can be updated'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/56933
const
String
hintText
=
'hint'
;
TextAlignVertical
alignment
=
TextAlignVertical
.
top
;
StateSetter
setState
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setter
)
{
setState
=
setter
;
return
InputDecorator
(
textAlignVertical:
alignment
,
decoration:
const
InputDecoration
(
hintText:
hintText
,
),
);
},
),
),
);
final
double
topPosition
=
tester
.
getTopLeft
(
find
.
text
(
hintText
)).
dy
;
setState
(()
{
alignment
=
TextAlignVertical
.
bottom
;
});
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
hintText
)).
dy
,
greaterThan
(
topPosition
));
// Setting textAlignVertical back to null works and reverts to the default.
setState
(()
{
alignment
=
null
;
});
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
hintText
)).
dy
,
topPosition
);
});
}
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