mirror of
https://github.com/flutter/flutter
synced 2024-08-24 18:36:03 +00:00
Instrument CurvedAnimation. (#143007)
This commit is contained in:
parent
10f1e63579
commit
ac5c3dec87
|
@ -379,6 +379,15 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
|
|||
required this.curve,
|
||||
this.reverseCurve,
|
||||
}) {
|
||||
// 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: '$CurvedAnimation',
|
||||
object: this,
|
||||
);
|
||||
}
|
||||
_updateCurveDirection(parent.status);
|
||||
parent.addStatusListener(_updateCurveDirection);
|
||||
}
|
||||
|
@ -433,6 +442,11 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
|
|||
|
||||
/// Cleans up any listeners added by this CurvedAnimation.
|
||||
void dispose() {
|
||||
// TODO(polina-c): stop duplicating code across disposables
|
||||
// https://github.com/flutter/flutter/issues/137435
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
isDisposed = true;
|
||||
parent.removeStatusListener(_updateCurveDirection);
|
||||
}
|
||||
|
|
|
@ -512,4 +512,19 @@ FlutterError
|
|||
expect(animation.value, 10.0);
|
||||
});
|
||||
|
||||
test('$CurvedAnimation dispatches memory events', () async {
|
||||
await expectLater(
|
||||
await memoryEvents(
|
||||
() => CurvedAnimation(
|
||||
parent: AnimationController(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
vsync: const TestVSync(),
|
||||
),
|
||||
curve: Curves.linear,
|
||||
).dispose(),
|
||||
CurvedAnimation,
|
||||
),
|
||||
areCreateAndDispose,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue