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
8769f94c
Unverified
Commit
8769f94c
authored
Feb 13, 2020
by
Gary Qian
Committed by
GitHub
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add textHeightBehavior and textWidthBasis to AnimatedDefaultTextStyle (#50748)
parent
f4177a6d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
implicit_animations.dart
packages/flutter/lib/src/widgets/implicit_animations.dart
+21
-2
default_text_style_test.dart
packages/flutter/test/widgets/default_text_style_test.dart
+11
-0
No files found.
packages/flutter/lib/src/widgets/implicit_animations.dart
View file @
8769f94c
...
...
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
TextHeightBehavior
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
...
@@ -1502,8 +1505,9 @@ class _SliverAnimatedOpacityState extends ImplicitlyAnimatedWidgetState<SliverAn
/// without explicit style) over a given duration whenever the given style
/// changes.
///
/// The [textAlign], [softWrap], [textOverflow], and [maxLines] properties are
/// not animated and take effect immediately when changed.
/// The [textAlign], [softWrap], [textOverflow], [maxLines], [textWidthBasis]
/// and [textHeightBehavior] properties are not animated and take effect
/// immediately when changed.
///
/// Here's an illustration of what using this widget looks like, using a [curve]
/// of [Curves.elasticInOut].
...
...
@@ -1529,6 +1533,8 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget {
this
.
softWrap
=
true
,
this
.
overflow
=
TextOverflow
.
clip
,
this
.
maxLines
,
this
.
textWidthBasis
=
TextWidthBasis
.
parent
,
this
.
textHeightBehavior
,
Curve
curve
=
Curves
.
linear
,
@required
Duration
duration
,
VoidCallback
onEnd
,
...
...
@@ -1537,6 +1543,7 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget {
assert
(
softWrap
!=
null
),
assert
(
overflow
!=
null
),
assert
(
maxLines
==
null
||
maxLines
>
0
),
assert
(
textWidthBasis
!=
null
),
super
(
key:
key
,
curve:
curve
,
duration:
duration
,
onEnd:
onEnd
);
/// The widget below this widget in the tree.
...
...
@@ -1575,6 +1582,14 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget {
/// See [DefaultTextStyle.maxLines] for more details.
final
int
maxLines
;
/// The strategy to use when calculating the width of the Text.
///
/// See [TextWidthBasis] for possible values and their implications.
final
TextWidthBasis
textWidthBasis
;
/// {@macro flutter.dart:ui.textHeightBehavior}
final
ui
.
TextHeightBehavior
textHeightBehavior
;
@override
_AnimatedDefaultTextStyleState
createState
()
=>
_AnimatedDefaultTextStyleState
();
...
...
@@ -1586,6 +1601,8 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget {
properties
.
add
(
FlagProperty
(
'softWrap'
,
value:
softWrap
,
ifTrue:
'wrapping at box width'
,
ifFalse:
'no wrapping except at line break characters'
,
showName:
true
));
properties
.
add
(
EnumProperty
<
TextOverflow
>(
'overflow'
,
overflow
,
defaultValue:
null
));
properties
.
add
(
IntProperty
(
'maxLines'
,
maxLines
,
defaultValue:
null
));
properties
.
add
(
EnumProperty
<
TextWidthBasis
>(
'textWidthBasis'
,
textWidthBasis
,
defaultValue:
TextWidthBasis
.
parent
));
properties
.
add
(
DiagnosticsProperty
<
ui
.
TextHeightBehavior
>(
'textHeightBehavior'
,
textHeightBehavior
,
defaultValue:
null
));
}
}
...
...
@@ -1605,6 +1622,8 @@ class _AnimatedDefaultTextStyleState extends AnimatedWidgetBaseState<AnimatedDef
softWrap:
widget
.
softWrap
,
overflow:
widget
.
overflow
,
maxLines:
widget
.
maxLines
,
textWidthBasis:
widget
.
textWidthBasis
,
textHeightBehavior:
widget
.
textHeightBehavior
,
child:
widget
.
child
,
);
}
...
...
packages/flutter/test/widgets/default_text_style_test.dart
View file @
8769f94c
...
...
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
TextHeightBehavior
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/painting.dart'
;
void
main
(
)
{
testWidgets
(
'DefaultTextStyle changes propagate to Text'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -67,6 +70,8 @@ void main() {
expect
(
text1
.
softWrap
,
isTrue
);
expect
(
text1
.
overflow
,
TextOverflow
.
clip
);
expect
(
text1
.
maxLines
,
isNull
);
expect
(
text1
.
textWidthBasis
,
TextWidthBasis
.
parent
);
expect
(
text1
.
textHeightBehavior
,
isNull
);
await
tester
.
pumpWidget
(
const
AnimatedDefaultTextStyle
(
style:
s2
,
...
...
@@ -74,6 +79,8 @@ void main() {
softWrap:
false
,
overflow:
TextOverflow
.
fade
,
maxLines:
3
,
textWidthBasis:
TextWidthBasis
.
longestLine
,
textHeightBehavior:
ui
.
TextHeightBehavior
(
applyHeightToFirstAscent:
false
),
child:
textWidget
,
duration:
Duration
(
milliseconds:
1000
),
));
...
...
@@ -85,6 +92,8 @@ void main() {
expect
(
text2
.
softWrap
,
false
);
expect
(
text2
.
overflow
,
TextOverflow
.
fade
);
expect
(
text2
.
maxLines
,
3
);
expect
(
text2
.
textWidthBasis
,
TextWidthBasis
.
longestLine
);
expect
(
text2
.
textHeightBehavior
,
const
ui
.
TextHeightBehavior
(
applyHeightToFirstAscent:
false
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
1000
));
...
...
@@ -95,5 +104,7 @@ void main() {
expect
(
text3
.
softWrap
,
false
);
expect
(
text3
.
overflow
,
TextOverflow
.
fade
);
expect
(
text3
.
maxLines
,
3
);
expect
(
text2
.
textWidthBasis
,
TextWidthBasis
.
longestLine
);
expect
(
text2
.
textHeightBehavior
,
const
ui
.
TextHeightBehavior
(
applyHeightToFirstAscent:
false
));
});
}
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