File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -509,6 +509,15 @@ class TrainHoppingAnimation extends Animation<double>
509
509
this ._nextTrain, {
510
510
this .onSwitchedTrain,
511
511
}) {
512
+ // TODO(polina-c): stop duplicating code across disposables
513
+ // https://github.com/flutter/flutter/issues/137435
514
+ if (kFlutterMemoryAllocationsEnabled) {
515
+ FlutterMemoryAllocations .instance.dispatchObjectCreated (
516
+ library: 'package:flutter/animation.dart' ,
517
+ className: '$TrainHoppingAnimation ' ,
518
+ object: this ,
519
+ );
520
+ }
512
521
if (_nextTrain != null ) {
513
522
if (_currentTrain! .value == _nextTrain! .value) {
514
523
_currentTrain = _nextTrain;
@@ -595,6 +604,11 @@ class TrainHoppingAnimation extends Animation<double>
595
604
/// After this is called, this object is no longer usable.
596
605
@override
597
606
void dispose () {
607
+ // TODO(polina-c): stop duplicating code across disposables
608
+ // https://github.com/flutter/flutter/issues/137435
609
+ if (kFlutterMemoryAllocationsEnabled) {
610
+ FlutterMemoryAllocations .instance.dispatchObjectDisposed (object: this );
611
+ }
598
612
assert (_currentTrain != null );
599
613
_currentTrain! .removeStatusListener (_statusChangeHandler);
600
614
_currentTrain! .removeListener (_valueChangeHandler);
Original file line number Diff line number Diff line change 4
4
5
5
import 'package:flutter/widgets.dart' ;
6
6
import 'package:flutter_test/flutter_test.dart' ;
7
+ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart' ;
7
8
8
9
import '../scheduler/scheduler_tester.dart' ;
9
10
@@ -127,6 +128,19 @@ void main() {
127
128
expect (animation.toString (), contains ('no next' ));
128
129
});
129
130
131
+ test ('TrainHoppingAnimation dispatches memory events' , () async {
132
+ await expectLater (
133
+ await memoryEvents (
134
+ () => TrainHoppingAnimation (
135
+ const AlwaysStoppedAnimation <double >(1 ),
136
+ const AlwaysStoppedAnimation <double >(1 ),
137
+ ).dispose (),
138
+ TrainHoppingAnimation ,
139
+ ),
140
+ areCreateAndDispose,
141
+ );
142
+ });
143
+
130
144
test ('AnimationMean control test' , () {
131
145
final AnimationController left = AnimationController (
132
146
value: 0.5 ,
You can’t perform that action at this time.
0 commit comments