TrainHoppingAnimation should dispatch creation and disposal events. (#141635)
This commit is contained in:
committed by
GitHub
parent
0503c44718
commit
e36a868beb
@@ -509,6 +509,15 @@ class TrainHoppingAnimation extends Animation<double>
|
||||
this._nextTrain, {
|
||||
this.onSwitchedTrain,
|
||||
}) {
|
||||
// TODO(polina-c): stop duplicating code across disposables
|
||||
// https://github.com/flutter/flutter/issues/137435
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
FlutterMemoryAllocations.instance.dispatchObjectCreated(
|
||||
library: 'package:flutter/animation.dart',
|
||||
className: '$TrainHoppingAnimation',
|
||||
object: this,
|
||||
);
|
||||
}
|
||||
if (_nextTrain != null) {
|
||||
if (_currentTrain!.value == _nextTrain!.value) {
|
||||
_currentTrain = _nextTrain;
|
||||
@@ -595,6 +604,11 @@ class TrainHoppingAnimation extends Animation<double>
|
||||
/// After this is called, this object is no longer usable.
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO(polina-c): stop duplicating code across disposables
|
||||
// https://github.com/flutter/flutter/issues/137435
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
assert(_currentTrain != null);
|
||||
_currentTrain!.removeStatusListener(_statusChangeHandler);
|
||||
_currentTrain!.removeListener(_valueChangeHandler);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
import '../scheduler/scheduler_tester.dart';
|
||||
|
||||
@@ -127,6 +128,19 @@ void main() {
|
||||
expect(animation.toString(), contains('no next'));
|
||||
});
|
||||
|
||||
test('TrainHoppingAnimation dispatches memory events', () async {
|
||||
await expectLater(
|
||||
await memoryEvents(
|
||||
() => TrainHoppingAnimation(
|
||||
const AlwaysStoppedAnimation<double>(1),
|
||||
const AlwaysStoppedAnimation<double>(1),
|
||||
).dispose(),
|
||||
TrainHoppingAnimation,
|
||||
),
|
||||
areCreateAndDispose,
|
||||
);
|
||||
});
|
||||
|
||||
test('AnimationMean control test', () {
|
||||
final AnimationController left = AnimationController(
|
||||
value: 0.5,
|
||||
|
||||
Reference in New Issue
Block a user