diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 0d683e3f23..df42645275 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -1005,6 +1005,12 @@ class ModalBottomSheetRoute extends PopupRoute { final ValueNotifier _clipDetailsNotifier = ValueNotifier(EdgeInsets.zero); + @override + void dispose() { + _clipDetailsNotifier.dispose(); + super.dispose(); + } + /// Updates the details regarding how the [SemanticsNode.rect] (focus) of /// the barrier for this [ModalBottomSheetRoute] should be clipped. /// diff --git a/packages/flutter/test/material/bottom_sheet_test.dart b/packages/flutter/test/material/bottom_sheet_test.dart index 49695c859f..886b3d1efa 100644 --- a/packages/flutter/test/material/bottom_sheet_test.dart +++ b/packages/flutter/test/material/bottom_sheet_test.dart @@ -7,6 +7,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; import '../widgets/semantics_tester.dart'; @@ -1672,7 +1673,8 @@ void main() { }); group('Modal BottomSheet avoids overlapping display features', () { - testWidgets('positioning using anchorPoint', (WidgetTester tester) async { + testWidgetsWithLeakTracking('positioning using anchorPoint', + (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( builder: (BuildContext context, Widget? child) { @@ -1708,7 +1710,12 @@ void main() { // Should take the right side of the screen expect(tester.getTopLeft(find.byType(Placeholder)).dx, 410); expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800); - }); + }, + leakTrackingTestConfig: const LeakTrackingTestConfig( + // TODO(polina-c): remove after fix + // https://github.com/flutter/flutter/issues/133594 + notDisposedAllowList: {'ValueNotifier': 1} + )); testWidgets('positioning using Directionality', (WidgetTester tester) async { await tester.pumpWidget(