Unverified Commit ac5c3dec authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Instrument CurvedAnimation. (#143007)

parent 10f1e635
......@@ -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,
);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment