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
59783d0f
Unverified
Commit
59783d0f
authored
Jan 11, 2021
by
Renzo Olivares
Committed by
GitHub
Jan 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selecting spaces on SelectableText (mobile) (#73300)
parent
66145fe6
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
307 additions
and
28 deletions
+307
-28
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+13
-19
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+294
-9
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
59783d0f
...
...
@@ -1950,33 +1950,26 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
if
(
obscureText
)
{
return
TextSelection
(
baseOffset:
0
,
extentOffset:
_plainText
.
length
);
// If the word is a space, on iOS try to select the previous word instead.
}
else
if
(
text
?.
text
!=
null
&&
_isWhitespace
(
text
!.
text
!.
codeUnitAt
(
position
.
offset
))
// On Android try to select the previous word instead only if the text is read only.
}
else
if
(
text
?.
toPlainText
()
!=
null
&&
_isWhitespace
(
text
!.
toPlainText
().
codeUnitAt
(
position
.
offset
))
&&
position
.
offset
>
0
)
{
assert
(
defaultTargetPlatform
!=
null
);
final
TextRange
?
previousWord
=
_getPreviousWord
(
word
.
start
);
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
int
startIndex
=
position
.
offset
-
1
;
while
(
startIndex
>
0
&&
(
_isWhitespace
(
text
!.
text
!.
codeUnitAt
(
startIndex
))
||
text
!.
text
!
==
'
\
u200e'
||
text
!.
text
!
==
'
\
u200f'
))
{
startIndex
--;
}
if
(
startIndex
>
0
)
{
final
TextPosition
positionBeforeSpace
=
TextPosition
(
offset:
startIndex
,
affinity:
position
.
affinity
,
);
final
TextRange
wordBeforeSpace
=
_textPainter
.
getWordBoundary
(
positionBeforeSpace
,
);
startIndex
=
wordBeforeSpace
.
start
;
}
return
TextSelection
(
baseOffset:
startIndex
,
baseOffset:
previousWord
!.
start
,
extentOffset:
position
.
offset
,
);
case
TargetPlatform
.
android
:
if
(
readOnly
)
{
return
TextSelection
(
baseOffset:
previousWord
!.
start
,
extentOffset:
position
.
offset
,
);
}
break
;
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
linux
:
...
...
@@ -1984,6 +1977,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
break
;
}
}
return
TextSelection
(
baseOffset:
word
.
start
,
extentOffset:
word
.
end
);
}
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
59783d0f
This diff is collapsed.
Click to expand it.
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