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
1075b2a1
Unverified
Commit
1075b2a1
authored
Apr 09, 2021
by
Justin McCandless
Committed by
GitHub
Apr 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a potentially missing TextSelectionOverlay dispose (#79988)
parent
c5fdb82d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+1
-1
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+65
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
1075b2a1
...
...
@@ -2139,7 +2139,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
// EditableWidget, not just changes triggered by user gestures.
requestKeyboard
();
if
(
widget
.
selectionControls
==
null
)
{
_selectionOverlay
?.
hid
e
();
_selectionOverlay
?.
dispos
e
();
_selectionOverlay
=
null
;
}
else
{
if
(
_selectionOverlay
==
null
)
{
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
1075b2a1
...
...
@@ -7367,6 +7367,71 @@ void main() {
expect
(
controller
.
selection
.
baseOffset
,
1
);
}
});
testWidgets
(
'the toolbar is disposed when selection changes and there is no selectionControls'
,
(
WidgetTester
tester
)
async
{
late
StateSetter
setState
;
bool
enableInteractiveSelection
=
true
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setter
)
{
setState
=
setter
;
return
EditableText
(
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
enableInteractiveSelection
?
materialTextSelectionControls
:
null
,
controller:
controller
,
enableInteractiveSelection:
enableInteractiveSelection
,
);
},
),
),
),
),
);
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
// Can't show the toolbar when there's no focus.
expect
(
state
.
showToolbar
(),
false
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
// Can show the toolbar when focused even though there's no text.
state
.
renderEditable
.
selectWordsInRange
(
from:
Offset
.
zero
,
cause:
SelectionChangedCause
.
tap
,
);
await
tester
.
pump
();
expect
(
state
.
showToolbar
(),
isTrue
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Paste'
),
findsOneWidget
);
// Find the FadeTransition in the toolbar and expect that it has not been
// disposed.
final
FadeTransition
fadeTransition
=
find
.
byType
(
FadeTransition
).
evaluate
()
.
map
((
Element
element
)
=>
element
.
widget
as
FadeTransition
)
.
firstWhere
((
FadeTransition
fadeTransition
)
{
return
fadeTransition
.
child
is
CompositedTransformFollower
;
});
expect
(
fadeTransition
.
toString
(),
isNot
(
contains
(
'DISPOSED'
)));
// Turn off interactive selection and change the text, which triggers the
// toolbar to be disposed.
setState
(()
{
enableInteractiveSelection
=
false
;
});
await
tester
.
pump
();
await
tester
.
enterText
(
find
.
byType
(
EditableText
),
'abc'
);
await
tester
.
pump
();
expect
(
fadeTransition
.
toString
(),
contains
(
'DISPOSED'
));
},
skip:
kIsWeb
);
}
class
UnsettableController
extends
TextEditingController
{
...
...
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