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
1d0cbbb2
Unverified
Commit
1d0cbbb2
authored
Feb 07, 2023
by
xubaolin
Committed by
GitHub
Feb 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a [SelectableRegion] crash bug (#120076)
* fix a crash bug * review feedback
parent
cf3fc017
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
5 deletions
+50
-5
selectable_region.dart
packages/flutter/lib/src/widgets/selectable_region.dart
+4
-4
selection_container.dart
packages/flutter/lib/src/widgets/selection_container.dart
+15
-1
selectable_region_test.dart
packages/flutter/test/widgets/selectable_region_test.dart
+31
-0
No files found.
packages/flutter/lib/src/widgets/selectable_region.dart
View file @
1d0cbbb2
...
...
@@ -1771,11 +1771,11 @@ abstract class MultiSelectableSelectionContainerDelegate extends SelectionContai
LayerLink
?
effectiveStartHandle
=
_startHandleLayer
;
LayerLink
?
effectiveEndHandle
=
_endHandleLayer
;
if
(
effectiveStartHandle
!=
null
||
effectiveEndHandle
!=
null
)
{
final
Rect
drawableArea
=
Rect
final
Rect
?
drawableArea
=
hasSize
?
Rect
.
fromLTWH
(
0
,
0
,
containerSize
.
width
,
containerSize
.
height
)
.
inflate
(
_kSelectionHandleDrawableAreaPadding
);
final
bool
hideStartHandle
=
value
.
startSelectionPoint
==
null
||
!
drawableArea
.
contains
(
value
.
startSelectionPoint
!.
localPosition
);
final
bool
hideEndHandle
=
value
.
endSelectionPoint
==
null
||
!
drawableArea
.
contains
(
value
.
endSelectionPoint
!.
localPosition
);
.
inflate
(
_kSelectionHandleDrawableAreaPadding
)
:
null
;
final
bool
hideStartHandle
=
value
.
startSelectionPoint
==
null
||
drawableArea
==
null
||
!
drawableArea
.
contains
(
value
.
startSelectionPoint
!.
localPosition
);
final
bool
hideEndHandle
=
value
.
endSelectionPoint
==
null
||
drawableArea
==
null
||
!
drawableArea
.
contains
(
value
.
endSelectionPoint
!.
localPosition
);
effectiveStartHandle
=
hideStartHandle
?
null
:
_startHandleLayer
;
effectiveEndHandle
=
hideEndHandle
?
null
:
_endHandleLayer
;
}
...
...
packages/flutter/lib/src/widgets/selection_container.dart
View file @
1d0cbbb2
...
...
@@ -298,12 +298,26 @@ abstract class SelectionContainerDelegate implements SelectionHandler, Selection
return
box
.
getTransformTo
(
ancestor
);
}
/// Whether the [SelectionContainer] has undergone layout and has a size.
///
/// See also:
///
/// * [RenderBox.hasSize], which is used internally by this method.
bool
get
hasSize
{
assert
(
_selectionContainerContext
?.
findRenderObject
()
!=
null
,
'The _selectionContainerContext must have a renderObject, such as after the first build has completed.'
,
);
final
RenderBox
box
=
_selectionContainerContext
!.
findRenderObject
()!
as
RenderBox
;
return
box
.
hasSize
;
}
/// Gets the size of the [SelectionContainer] of this delegate.
///
/// Can only be called after [SelectionContainer] is laid out.
Size
get
containerSize
{
assert
(
_selectionContainerContext
?.
findRenderObject
()
!=
null
,
hasSize
,
'containerSize cannot be called before SelectionContainer is laid out.'
,
);
final
RenderBox
box
=
_selectionContainerContext
!.
findRenderObject
()!
as
RenderBox
;
...
...
packages/flutter/test/widgets/selectable_region_test.dart
View file @
1d0cbbb2
...
...
@@ -73,6 +73,37 @@ void main() {
await
gesture
.
up
();
},
skip:
kIsWeb
);
// https://github.com/flutter/flutter/issues/102410.
testWidgets
(
'Does not crash when using Navigator pages'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/119776
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Navigator
(
pages:
<
Page
<
void
>>
[
MaterialPage
<
void
>(
child:
Column
(
children:
<
Widget
>[
const
Text
(
'How are you?'
),
SelectableRegion
(
focusNode:
FocusNode
(),
selectionControls:
materialTextSelectionControls
,
child:
const
SelectAllWidget
(
child:
SizedBox
(
width:
100
,
height:
100
)),
),
const
Text
(
'Fine, thank you.'
),
],
),
),
const
MaterialPage
<
void
>(
child:
Scaffold
(
body:
Text
(
'Foreground Page'
)),
),
],
onPopPage:
(
_
,
__
)
=>
false
,
),
),
);
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'can draw handles when they are at rect boundaries'
,
(
WidgetTester
tester
)
async
{
final
UniqueKey
spy
=
UniqueKey
();
await
tester
.
pumpWidget
(
...
...
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