Unverified Commit 5d9983a1 authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

RenderAnnotatedRegion should dispose created layers. (#136086)

parent eec3f060
...@@ -4989,6 +4989,7 @@ class RenderAnnotatedRegion<T extends Object> extends RenderProxyBox { ...@@ -4989,6 +4989,7 @@ class RenderAnnotatedRegion<T extends Object> extends RenderProxyBox {
RenderBox? child, RenderBox? child,
}) : _value = value, }) : _value = value,
_sized = sized, _sized = sized,
_layerHandle = LayerHandle<AnnotatedRegionLayer<T>>(),
super(child); super(child);
/// A value which can be retrieved using [Layer.find]. /// A value which can be retrieved using [Layer.find].
...@@ -5013,6 +5014,8 @@ class RenderAnnotatedRegion<T extends Object> extends RenderProxyBox { ...@@ -5013,6 +5014,8 @@ class RenderAnnotatedRegion<T extends Object> extends RenderProxyBox {
markNeedsPaint(); markNeedsPaint();
} }
final LayerHandle<AnnotatedRegionLayer<T>> _layerHandle;
@override @override
final bool alwaysNeedsCompositing = true; final bool alwaysNeedsCompositing = true;
...@@ -5024,6 +5027,13 @@ class RenderAnnotatedRegion<T extends Object> extends RenderProxyBox { ...@@ -5024,6 +5027,13 @@ class RenderAnnotatedRegion<T extends Object> extends RenderProxyBox {
size: sized ? size : null, size: sized ? size : null,
offset: sized ? offset : null, offset: sized ? offset : null,
); );
_layerHandle.layer = layer;
context.pushLayer(layer, super.paint, offset); context.pushLayer(layer, super.paint, offset);
} }
@override
void dispose() {
_layerHandle.layer = null;
super.dispose();
}
} }
...@@ -552,12 +552,7 @@ void main() { ...@@ -552,12 +552,7 @@ void main() {
await gesture.moveTo(tester.getCenter(find.text('18'))); await gesture.moveTo(tester.getCenter(find.text('18')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(inkFeatures, paints..circle(color: datePickerTheme.rangeSelectionOverlayColor?.resolve(<MaterialState>{}))); expect(inkFeatures, paints..circle(color: datePickerTheme.rangeSelectionOverlayColor?.resolve(<MaterialState>{})));
}, });
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/136036
notDisposedAllowList: <String, int?> {'AnnotatedRegionLayer<SystemUiOverlayStyle>': 2},
));
testWidgetsWithLeakTracking('Dividers use DatePickerThemeData.dividerColor', (WidgetTester tester) async { testWidgetsWithLeakTracking('Dividers use DatePickerThemeData.dividerColor', (WidgetTester tester) async {
Future<void> showPicker(WidgetTester tester, Size size) async { Future<void> showPicker(WidgetTester tester, Size size) async {
...@@ -902,10 +897,5 @@ void main() { ...@@ -902,10 +897,5 @@ void main() {
..circle(color: rangeSelectionOverlayColor.resolve(<MaterialState>{MaterialState.pressed})), ..circle(color: rangeSelectionOverlayColor.resolve(<MaterialState>{MaterialState.pressed})),
); );
} }
}, });
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/136036
notDisposedAllowList: <String, int?> {'AnnotatedRegionLayer<SystemUiOverlayStyle>': 2},
));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment