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
c4df6b6d
Unverified
Commit
c4df6b6d
authored
Aug 02, 2022
by
xubaolin
Committed by
GitHub
Aug 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SelectionOverlay]Move the debug statement to the scope of the assertion. (#108508)
parent
61151488
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
48 additions
and
21 deletions
+48
-21
overlay.0.dart
examples/api/lib/widgets/overlay/overlay.0.dart
+1
-1
context_menu.dart
packages/flutter/lib/src/cupertino/context_menu.dart
+1
-1
bottom_navigation_bar.dart
packages/flutter/lib/src/material/bottom_navigation_bar.dart
+1
-1
range_slider.dart
packages/flutter/lib/src/material/range_slider.dart
+1
-1
slider.dart
packages/flutter/lib/src/material/slider.dart
+1
-1
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+1
-1
autocomplete.dart
packages/flutter/lib/src/widgets/autocomplete.dart
+1
-1
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+2
-1
reorderable_list.dart
packages/flutter/lib/src/widgets/reorderable_list.dart
+3
-3
selectable_region.dart
packages/flutter/lib/src/widgets/selectable_region.dart
+2
-1
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+3
-9
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+31
-0
No files found.
examples/api/lib/widgets/overlay/overlay.0.dart
View file @
c4df6b6d
...
...
@@ -132,7 +132,7 @@ class _OverlayExampleState extends State<OverlayExample> {
);
// Add the OverlayEntry to the Overlay.
Overlay
.
of
(
context
)!.
insert
(
overlayEntry
!);
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)!.
insert
(
overlayEntry
!);
}
// Remove the OverlayEntry.
...
...
packages/flutter/lib/src/cupertino/context_menu.dart
View file @
c4df6b6d
...
...
@@ -363,7 +363,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
);
},
);
Overlay
.
of
(
context
,
rootOverlay:
true
)!.
insert
(
_lastOverlayEntry
!);
Overlay
.
of
(
context
,
rootOverlay:
true
,
debugRequiredFor:
widget
)!.
insert
(
_lastOverlayEntry
!);
_openController
.
forward
();
}
...
...
packages/flutter/lib/src/material/bottom_navigation_bar.dart
View file @
c4df6b6d
...
...
@@ -1004,7 +1004,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
assert
(
debugCheckHasDirectionality
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
assert
(
debugCheckHasMediaQuery
(
context
));
assert
(
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)
!=
null
);
assert
(
debugCheckHasOverlay
(
context
)
);
final
BottomNavigationBarThemeData
bottomTheme
=
BottomNavigationBarTheme
.
of
(
context
);
final
BottomNavigationBarLandscapeLayout
layout
=
widget
.
landscapeLayout
...
...
packages/flutter/lib/src/material/range_slider.dart
View file @
c4df6b6d
...
...
@@ -655,7 +655,7 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
);
},
);
Overlay
.
of
(
context
)!.
insert
(
overlayEntry
!);
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)!.
insert
(
overlayEntry
!);
}
}
}
...
...
packages/flutter/lib/src/material/slider.dart
View file @
c4df6b6d
...
...
@@ -842,7 +842,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
);
},
);
Overlay
.
of
(
context
)!.
insert
(
overlayEntry
!);
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)!.
insert
(
overlayEntry
!);
}
}
}
...
...
packages/flutter/lib/src/material/tooltip.dart
View file @
c4df6b6d
...
...
@@ -698,7 +698,7 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
if
(
_tooltipMessage
.
isEmpty
)
{
return
widget
.
child
??
const
SizedBox
();
}
assert
(
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)
!=
null
);
assert
(
debugCheckHasOverlay
(
context
)
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
TooltipThemeData
tooltipTheme
=
TooltipTheme
.
of
(
context
);
final
TextStyle
defaultTextStyle
;
...
...
packages/flutter/lib/src/widgets/autocomplete.dart
View file @
c4df6b6d
...
...
@@ -432,7 +432,7 @@ class _RawAutocompleteState<T extends Object> extends State<RawAutocomplete<T>>
);
},
);
Overlay
.
of
(
context
,
rootOverlay:
true
)!.
insert
(
newFloatingOptions
);
Overlay
.
of
(
context
,
rootOverlay:
true
,
debugRequiredFor:
widget
)!.
insert
(
newFloatingOptions
);
_floatingOptions
=
newFloatingOptions
;
}
else
{
_floatingOptions
=
null
;
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
c4df6b6d
...
...
@@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import
'basic.dart'
;
import
'binding.dart'
;
import
'debug.dart'
;
import
'framework.dart'
;
import
'media_query.dart'
;
import
'overlay.dart'
;
...
...
@@ -598,7 +599,7 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
Overlay
.
of
(
context
,
debugRequiredFor:
widget
,
rootOverlay:
widget
.
rootOverlay
)
!=
null
);
assert
(
debugCheckHasOverlay
(
context
)
);
final
bool
canDrag
=
widget
.
maxSimultaneousDrags
==
null
||
_activeCount
<
widget
.
maxSimultaneousDrags
!;
final
bool
showChild
=
_activeCount
==
0
||
widget
.
childWhenDragging
==
null
;
...
...
packages/flutter/lib/src/widgets/reorderable_list.dart
View file @
c4df6b6d
...
...
@@ -702,7 +702,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
);
_dragInfo
!.
startDrag
();
final
OverlayState
overlay
=
Overlay
.
of
(
context
)!;
final
OverlayState
overlay
=
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)!;
assert
(
_overlayEntry
==
null
);
_overlayEntry
=
OverlayEntry
(
builder:
_dragInfo
!.
createProxy
);
overlay
.
insert
(
_overlayEntry
!);
...
...
@@ -897,7 +897,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
}
final
Widget
child
=
widget
.
itemBuilder
(
context
,
index
);
assert
(
child
.
key
!=
null
,
'All list items must have a key'
);
final
OverlayState
overlay
=
Overlay
.
of
(
context
)!;
final
OverlayState
overlay
=
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)!;
return
_ReorderableItem
(
key:
_ReorderableItemGlobalKey
(
child
.
key
!,
index
,
this
),
index:
index
,
...
...
@@ -1284,7 +1284,7 @@ class _DragInfo extends Drag {
}
Offset
_overlayOrigin
(
BuildContext
context
)
{
final
OverlayState
overlay
=
Overlay
.
of
(
context
)!;
final
OverlayState
overlay
=
Overlay
.
of
(
context
,
debugRequiredFor:
context
.
widget
)!;
final
RenderBox
overlayBox
=
overlay
.
context
.
findRenderObject
()!
as
RenderBox
;
return
overlayBox
.
localToGlobal
(
Offset
.
zero
);
}
...
...
packages/flutter/lib/src/widgets/selectable_region.dart
View file @
c4df6b6d
...
...
@@ -12,6 +12,7 @@ import 'package:flutter/services.dart';
import
'actions.dart'
;
import
'basic.dart'
;
import
'debug.dart'
;
import
'focus_manager.dart'
;
import
'focus_scope.dart'
;
import
'framework.dart'
;
...
...
@@ -804,7 +805,7 @@ class _SelectableRegionState extends State<SelectableRegion> with TextSelectionD
@override
Widget
build
(
BuildContext
context
)
{
assert
(
Overlay
.
of
(
context
,
debugRequiredFor:
widget
)
!=
null
);
assert
(
debugCheckHasOverlay
(
context
)
);
return
CompositedTransformTarget
(
link:
_toolbarLayerLink
,
child:
RawGestureDetector
(
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
c4df6b6d
...
...
@@ -16,6 +16,7 @@ import 'basic.dart';
import
'binding.dart'
;
import
'constants.dart'
;
import
'container.dart'
;
import
'debug.dart'
;
import
'editable_text.dart'
;
import
'framework.dart'
;
import
'gesture_detector.dart'
;
...
...
@@ -616,15 +617,8 @@ class SelectionOverlay {
_endHandleType
=
endHandleType
,
_lineHeightAtEnd
=
lineHeightAtEnd
,
_selectionEndpoints
=
selectionEndpoints
,
_toolbarLocation
=
toolbarLocation
{
final
OverlayState
?
overlay
=
Overlay
.
of
(
context
,
rootOverlay:
true
);
assert
(
overlay
!=
null
,
'No Overlay widget exists above
$context
.
\n
'
'Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your '
'app content was created above the Navigator with the WidgetsApp builder parameter.'
,
);
}
_toolbarLocation
=
toolbarLocation
,
assert
(
debugCheckHasOverlay
(
context
));
/// The context in which the selection handles should appear.
///
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
c4df6b6d
...
...
@@ -176,6 +176,37 @@ void main() {
);
}
testWidgets
(
'throw if no Overlay widget exists above'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
(
size:
Size
(
800.0
,
600.0
)),
child:
Center
(
child:
Material
(
child:
SelectableText
(
'I love Flutter!'
),
),
),
),
),
);
final
Offset
textFieldStart
=
tester
.
getTopLeft
(
find
.
byType
(
SelectableText
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
textFieldStart
,
kind:
PointerDeviceKind
.
mouse
);
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
final
FlutterError
error
=
tester
.
takeException
()
as
FlutterError
;
expect
(
error
.
message
,
contains
(
'EditableText widgets require an Overlay widget ancestor'
),
);
await
tester
.
pumpWidget
(
const
SizedBox
.
shrink
());
expect
(
tester
.
takeException
(),
isNotNull
);
// side effect exception
});
testWidgets
(
'Do not crash when remove SelectableText during handle drag'
,
(
WidgetTester
tester
)
async
{
// Regression test https://github.com/flutter/flutter/issues/108242
bool
isShow
=
true
;
...
...
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