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
d74a1bb0
Unverified
Commit
d74a1bb0
authored
Mar 29, 2023
by
Taha Tesser
Committed by
GitHub
Mar 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix off-screen selected text throws exception (#123595)
Fix off-screen selected text throws exception
parent
47c92c00
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
0 deletions
+61
-0
text_selection_toolbar_anchors.dart
...utter/lib/src/widgets/text_selection_toolbar_anchors.dart
+6
-0
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+55
-0
No files found.
packages/flutter/lib/src/widgets/text_selection_toolbar_anchors.dart
View file @
d74a1bb0
...
@@ -34,6 +34,12 @@ class TextSelectionToolbarAnchors {
...
@@ -34,6 +34,12 @@ class TextSelectionToolbarAnchors {
renderBox
.
localToGlobal
(
Offset
.
zero
),
renderBox
.
localToGlobal
(
Offset
.
zero
),
renderBox
.
localToGlobal
(
renderBox
.
size
.
bottomRight
(
Offset
.
zero
)),
renderBox
.
localToGlobal
(
renderBox
.
size
.
bottomRight
(
Offset
.
zero
)),
);
);
if
(
editingRegion
.
left
.
isNaN
||
editingRegion
.
top
.
isNaN
||
editingRegion
.
right
.
isNaN
||
editingRegion
.
bottom
.
isNaN
)
{
return
const
TextSelectionToolbarAnchors
(
primaryAnchor:
Offset
.
zero
);
}
final
bool
isMultiline
=
selectionEndpoints
.
last
.
point
.
dy
-
selectionEndpoints
.
first
.
point
.
dy
>
final
bool
isMultiline
=
selectionEndpoints
.
last
.
point
.
dy
-
selectionEndpoints
.
first
.
point
.
dy
>
endGlyphHeight
/
2
;
endGlyphHeight
/
2
;
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
d74a1bb0
...
@@ -5399,4 +5399,59 @@ void main() {
...
@@ -5399,4 +5399,59 @@ void main() {
);
);
expect
(
count
,
1
);
// The `onSelectionChanged` will not be triggered.
expect
(
count
,
1
);
// The `onSelectionChanged` will not be triggered.
});
});
testWidgets
(
"Off-screen selected text doesn't throw exception"
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/123527
TextSelection
?
selection
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
Column
(
children:
<
Widget
>[
Expanded
(
child:
ListView
.
builder
(
itemCount:
100
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
SelectableText
(
'I love Flutter!
$index
'
,
onSelectionChanged:
(
TextSelection
s
,
_
)
{
selection
=
s
;
},
);
},
),
),
TextButton
(
onPressed:
()
{
Navigator
.
pop
(
context
);
},
child:
const
Text
(
'Pop'
),
),
],
);
}
),
),
));
expect
(
selection
,
null
);
final
Offset
selectableTextStart
=
tester
.
getTopLeft
(
find
.
byType
(
SelectableText
).
first
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
selectableTextStart
+
const
Offset
(
50
,
5
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
await
gesture
.
up
();
expect
(
selection
,
isNotNull
);
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
-
3000.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'Pop'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
takeException
(),
isNull
);
});
}
}
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