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
1c1326ad
Unverified
Commit
1c1326ad
authored
Jun 23, 2020
by
MH Johnson
Committed by
GitHub
Jun 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add check for DefaultTextHeightBehavior in EditableText + tests (#59913)
parent
e8fa87e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
3 deletions
+69
-3
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+2
-1
text.dart
packages/flutter/lib/src/widgets/text.dart
+2
-2
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+65
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
1c1326ad
...
...
@@ -29,6 +29,7 @@ import 'media_query.dart';
import
'scroll_controller.dart'
;
import
'scroll_physics.dart'
;
import
'scrollable.dart'
;
import
'text.dart'
;
import
'text_selection.dart'
;
import
'ticker_provider.dart'
;
...
...
@@ -2253,7 +2254,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
textAlign:
widget
.
textAlign
,
textDirection:
_textDirection
,
locale:
widget
.
locale
,
textHeightBehavior:
widget
.
textHeightBehavior
,
textHeightBehavior:
widget
.
textHeightBehavior
??
DefaultTextHeightBehavior
.
of
(
context
)
,
textWidthBasis:
widget
.
textWidthBasis
,
obscuringCharacter:
widget
.
obscuringCharacter
,
obscureText:
widget
.
obscureText
,
...
...
packages/flutter/lib/src/widgets/text.dart
View file @
1c1326ad
...
...
@@ -203,8 +203,8 @@ class DefaultTextStyle extends InheritedTheme {
}
}
/// The [TextHeightBehavior] that will apply to descendant [Text]
widgets which
/// have not explicitly set [Text.textHeightBehavior].
/// The [TextHeightBehavior] that will apply to descendant [Text]
and [EditableText]
///
widgets which
have not explicitly set [Text.textHeightBehavior].
///
/// If there is a [DefaultTextStyle] with a non-null [DefaultTextStyle.textHeightBehavior]
/// below this widget, the [DefaultTextStyle.textHeightBehavior] will be used
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
1c1326ad
...
...
@@ -129,6 +129,7 @@ void main() {
expect
(
editableText
.
enableSuggestions
,
isTrue
);
expect
(
editableText
.
textAlign
,
TextAlign
.
start
);
expect
(
editableText
.
cursorWidth
,
2.0
);
expect
(
editableText
.
textHeightBehavior
,
isNull
);
});
testWidgets
(
'text keyboard is requested when maxLines is default'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -5062,6 +5063,70 @@ void main() {
));
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
antiAlias
));
});
testWidgets
(
'EditableText inherits DefaultTextHeightBehavior'
,
(
WidgetTester
tester
)
async
{
const
TextHeightBehavior
customTextHeightBehavior
=
TextHeightBehavior
(
applyHeightToLastDescent:
true
,
applyHeightToFirstAscent:
false
,
);
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
FocusScope
(
node:
focusScopeNode
,
autofocus:
true
,
child:
DefaultTextHeightBehavior
(
textHeightBehavior:
customTextHeightBehavior
,
child:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
),
));
final
RenderEditable
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
expect
(
renderObject
.
textHeightBehavior
,
equals
(
customTextHeightBehavior
));
});
testWidgets
(
'EditableText defaultTextHeightBehavior is used over inherited widget'
,
(
WidgetTester
tester
)
async
{
const
TextHeightBehavior
inheritedTextHeightBehavior
=
TextHeightBehavior
(
applyHeightToLastDescent:
true
,
applyHeightToFirstAscent:
false
,
);
const
TextHeightBehavior
customTextHeightBehavior
=
TextHeightBehavior
(
applyHeightToLastDescent:
false
,
applyHeightToFirstAscent:
false
,
);
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
FocusScope
(
node:
focusScopeNode
,
autofocus:
true
,
child:
DefaultTextHeightBehavior
(
textHeightBehavior:
inheritedTextHeightBehavior
,
child:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
textHeightBehavior:
customTextHeightBehavior
,
),
),
),
),
));
final
RenderEditable
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
expect
(
renderObject
.
textHeightBehavior
,
isNot
(
equals
(
inheritedTextHeightBehavior
)));
expect
(
renderObject
.
textHeightBehavior
,
equals
(
customTextHeightBehavior
));
});
}
class
MockTextFormatter
extends
TextInputFormatter
{
...
...
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