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
478d1dae
Unverified
Commit
478d1dae
authored
Jan 09, 2023
by
Lucas.Xu
Committed by
GitHub
Jan 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove the unused check in selectable_text (#117716)
parent
6c225dda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
8 deletions
+41
-8
selectable_text.dart
packages/flutter/lib/src/material/selectable_text.dart
+2
-8
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+39
-0
No files found.
packages/flutter/lib/src/material/selectable_text.dart
View file @
478d1dae
...
...
@@ -558,8 +558,6 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
});
}
TextSelection
?
_lastSeenTextSelection
;
void
_handleSelectionChanged
(
TextSelection
selection
,
SelectionChangedCause
?
cause
)
{
final
bool
willShowSelectionHandles
=
_shouldShowSelectionHandles
(
cause
);
if
(
willShowSelectionHandles
!=
_showSelectionHandles
)
{
...
...
@@ -567,12 +565,8 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
_showSelectionHandles
=
willShowSelectionHandles
;
});
}
// TODO(chunhtai): The selection may be the same. We should remove this
// check once this is fixed https://github.com/flutter/flutter/issues/76349.
if
(
widget
.
onSelectionChanged
!=
null
&&
_lastSeenTextSelection
!=
selection
)
{
widget
.
onSelectionChanged
!(
selection
,
cause
);
}
_lastSeenTextSelection
=
selection
;
widget
.
onSelectionChanged
?.
call
(
selection
,
cause
);
switch
(
Theme
.
of
(
context
).
platform
)
{
case
TargetPlatform
.
iOS
:
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
478d1dae
...
...
@@ -5367,4 +5367,43 @@ void main() {
final
EditableText
editableText
=
tester
.
widget
(
find
.
byType
(
EditableText
));
expect
(
editableText
.
style
.
fontSize
,
textStyle
.
fontSize
);
});
testWidgets
(
'SelectableText text span style is merged with default text style'
,
(
WidgetTester
tester
)
async
{
TextSelection
?
selection
;
int
count
=
0
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
SelectableText
(
'I love Flutter!'
,
onSelectionChanged:
(
TextSelection
s
,
_
)
{
selection
=
s
;
count
++;
},
),
),
);
expect
(
selection
,
null
);
expect
(
count
,
0
);
// Tap to put the cursor before the "F".
const
int
index
=
7
;
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
index
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
selection
,
const
TextSelection
.
collapsed
(
offset:
index
),
);
expect
(
count
,
1
);
// The `onSelectionChanged` will be triggered one time.
// Tap on the same location again.
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
index
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
selection
,
const
TextSelection
.
collapsed
(
offset:
index
),
);
expect
(
count
,
1
);
// The `onSelectionChanged` will not be triggered.
});
}
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