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
0ec73510
Commit
0ec73510
authored
Dec 18, 2019
by
神楽坂花火
Committed by
Flutter GitHub Bot
Dec 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add textScaleFactor to SelectableText (#44682)
parent
65ad8d80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
26 deletions
+37
-26
selectable_text.dart
packages/flutter/lib/src/material/selectable_text.dart
+8
-1
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+29
-25
No files found.
packages/flutter/lib/src/material/selectable_text.dart
View file @
0ec73510
...
...
@@ -48,7 +48,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
_SelectableTextSelectionGestureDetectorBuilder
({
@required
_SelectableTextState
state
,
})
:
_state
=
state
,
super
(
delegate:
state
);
super
(
delegate:
state
);
final
_SelectableTextState
_state
;
...
...
@@ -201,6 +201,7 @@ class SelectableText extends StatefulWidget {
this
.
strutStyle
,
this
.
textAlign
,
this
.
textDirection
,
this
.
textScaleFactor
,
this
.
showCursor
=
false
,
this
.
autofocus
=
false
,
ToolbarOptions
toolbarOptions
,
...
...
@@ -243,6 +244,7 @@ class SelectableText extends StatefulWidget {
this
.
strutStyle
,
this
.
textAlign
,
this
.
textDirection
,
this
.
textScaleFactor
,
this
.
showCursor
=
false
,
this
.
autofocus
=
false
,
ToolbarOptions
toolbarOptions
,
...
...
@@ -321,6 +323,9 @@ class SelectableText extends StatefulWidget {
/// {@macro flutter.widgets.editableText.textDirection}
final
TextDirection
textDirection
;
/// {@macro flutter.widgets.editableText.textScaleFactor}
final
double
textScaleFactor
;
/// {@macro flutter.widgets.editableText.autofocus}
final
bool
autofocus
;
...
...
@@ -396,6 +401,7 @@ class SelectableText extends StatefulWidget {
properties
.
add
(
IntProperty
(
'maxLines'
,
maxLines
,
defaultValue:
null
));
properties
.
add
(
EnumProperty
<
TextAlign
>(
'textAlign'
,
textAlign
,
defaultValue:
null
));
properties
.
add
(
EnumProperty
<
TextDirection
>(
'textDirection'
,
textDirection
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'textScaleFactor'
,
textScaleFactor
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'cursorWidth'
,
cursorWidth
,
defaultValue:
2.0
));
properties
.
add
(
DiagnosticsProperty
<
Radius
>(
'cursorRadius'
,
cursorRadius
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'cursorColor'
,
cursorColor
,
defaultValue:
null
));
...
...
@@ -572,6 +578,7 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
strutStyle:
widget
.
strutStyle
??
StrutStyle
.
disabled
,
textAlign:
widget
.
textAlign
??
defaultTextStyle
.
textAlign
??
TextAlign
.
start
,
textDirection:
widget
.
textDirection
,
textScaleFactor:
widget
.
textScaleFactor
,
autofocus:
widget
.
autofocus
,
forceLine:
false
,
toolbarOptions:
widget
.
toolbarOptions
,
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
0ec73510
...
...
@@ -177,10 +177,7 @@ void main() {
debugResetSemanticsIdCounter
();
});
Widget
selectableTextBuilder
({
String
text
=
''
,
int
maxLines
=
1
,
})
{
Widget
selectableTextBuilder
({
String
text
=
''
,
int
maxLines
=
1
})
{
return
boilerplate
(
child:
SelectableText
(
text
,
...
...
@@ -192,17 +189,12 @@ void main() {
testWidgets
(
'has expected defaults'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MediaQuery
(
data:
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SelectableText
(
'selectable text'
),
),
boilerplate
(
child:
const
SelectableText
(
'selectable text'
),
),
);
final
SelectableText
selectableText
=
tester
.
firstWidget
(
find
.
byType
(
SelectableText
));
final
SelectableText
selectableText
=
tester
.
firstWidget
(
find
.
byType
(
SelectableText
));
expect
(
selectableText
.
showCursor
,
false
);
expect
(
selectableText
.
autofocus
,
false
);
expect
(
selectableText
.
dragStartBehavior
,
DragStartBehavior
.
start
);
...
...
@@ -328,6 +320,29 @@ void main() {
expect
(
longtextBox
.
size
,
const
Size
(
199.0
,
14.0
));
});
testWidgets
(
'can scale with textScaleFactor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
SelectableText
(
'selectable text'
),
),
);
final
RenderBox
renderBox
=
tester
.
renderObject
(
find
.
byType
(
SelectableText
));
expect
(
renderBox
.
size
.
height
,
14.0
);
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
SelectableText
(
'selectable text'
,
textScaleFactor:
1.9
,
),
),
);
final
RenderBox
scaledBox
=
tester
.
renderObject
(
find
.
byType
(
SelectableText
));
expect
(
scaledBox
.
size
.
height
,
27.0
);
});
testWidgets
(
'can switch between textWidthBasis'
,
(
WidgetTester
tester
)
async
{
RenderBox
findTextBox
()
=>
tester
.
renderObject
(
find
.
byType
(
SelectableText
));
const
String
text
=
'I can face roll keyboardkeyboardaszzaaaaszzaaaaszzaaaaszzaaaa'
;
...
...
@@ -3186,25 +3201,13 @@ void main() {
testWidgets
(
'SelectableText implements debugFillProperties'
,
(
WidgetTester
tester
)
async
{
final
DiagnosticPropertiesBuilder
builder
=
DiagnosticPropertiesBuilder
();
// properties.add(DiagnosticsProperty<String>('data', data, defaultValue: null));
// properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
// properties.add(DiagnosticsProperty<TextStyle>('style', style, defaultValue: null));
// properties.add(DiagnosticsProperty<bool>('autofocus', autofocus, defaultValue: false));
// properties.add(DiagnosticsProperty<bool>('showCursor', showCursor, defaultValue: false));
// properties.add(IntProperty('maxLines', maxLines, defaultValue: null));
// properties.add(EnumProperty<TextAlign>('textAlign', textAlign, defaultValue: null));
// properties.add(EnumProperty<TextDirection>('textDirection', textDirection, defaultValue: null));
// properties.add(DoubleProperty('cursorWidth', cursorWidth, defaultValue: 2.0));
// properties.add(DiagnosticsProperty<Radius>('cursorRadius', cursorRadius, defaultValue: null));
// properties.add(DiagnosticsProperty<Color>('cursorColor', cursorColor, defaultValue: null));
// properties.add(FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled'));
// properties.add(DiagnosticsProperty<ScrollPhysics>('scrollPhysics', scrollPhysics, defaultValue: null));
// Not checking controller, inputFormatters, focusNode
const
SelectableText
(
'something'
,
style:
TextStyle
(
color:
Color
(
0xff00ff00
)),
textAlign:
TextAlign
.
end
,
textDirection:
TextDirection
.
ltr
,
textScaleFactor:
1.0
,
autofocus:
true
,
showCursor:
true
,
maxLines:
10
,
...
...
@@ -3227,6 +3230,7 @@ void main() {
'maxLines: 10'
,
'textAlign: end'
,
'textDirection: ltr'
,
'textScaleFactor: 1.0'
,
'cursorWidth: 1.0'
,
'cursorRadius: Radius.circular(0.0)'
,
'cursorColor: Color(0xff00ff00)'
,
...
...
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