Skip to content

Commit

Permalink
Fix memory leak in BottomNavigationBar (#146748)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinVignal authored Apr 16, 2024
1 parent cb719db commit c3445dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/flutter/lib/src/material/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,9 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
for (final _Circle circle in _circles) {
circle.dispose();
}
for (final CurvedAnimation animation in _animations) {
animation.dispose();
}
super.dispose();
}

Expand Down
6 changes: 5 additions & 1 deletion packages/flutter/test/material/bottom_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -1282,7 +1283,10 @@ void main() {
await checkDragHandleAndColors();
});

testWidgets('showModalBottomSheet does not use root Navigator by default', (WidgetTester tester) async {
testWidgets('showModalBottomSheet does not use root Navigator by default',
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: const <String>['CurvedAnimation']),
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: Navigator(onGenerateRoute: (RouteSettings settings) => MaterialPageRoute<void>(builder: (_) {
Expand Down

0 comments on commit c3445dc

Please sign in to comment.