Shorten method signature to make invokations fit one line. (#163822)

Contributes to https://github.com/flutter/flutter/issues/137435.
This commit is contained in:
Polina Cherkasova 2025-02-24 14:09:56 -08:00 committed by GitHub
parent a4a5a33cfa
commit e1cce0b8b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 14 deletions

View File

@ -379,9 +379,7 @@ class ReverseAnimation extends Animation<double>
class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<double> { class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<double> {
/// Creates a curved animation. /// Creates a curved animation.
CurvedAnimation({required this.parent, required this.curve, this.reverseCurve}) { CurvedAnimation({required this.parent, required this.curve, this.reverseCurve}) {
assert( assert(debugMaybeDispatchCreated('animation', 'CurvedAnimation', this));
debugMaybeDispatchObjectCreated('package:flutter/animation.dart', 'CurvedAnimation', this),
);
_updateCurveDirection(parent.status); _updateCurveDirection(parent.status);
parent.addStatusListener(_updateCurveDirection); parent.addStatusListener(_updateCurveDirection);
} }
@ -428,7 +426,7 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
/// Cleans up any listeners added by this CurvedAnimation. /// Cleans up any listeners added by this CurvedAnimation.
void dispose() { void dispose() {
assert(debugMaybeDispatchObjectDisposed(this)); assert(debugMaybeDispatchDisposed(this));
isDisposed = true; isDisposed = true;
parent.removeStatusListener(_updateCurveDirection); parent.removeStatusListener(_updateCurveDirection);
} }

View File

@ -134,19 +134,22 @@ String? activeDevToolsServerAddress;
/// The uri for the connected vm service protocol. /// The uri for the connected vm service protocol.
String? connectedVmServiceUri; String? connectedVmServiceUri;
/// If memory allocation tracking is enabled, dispatch object creation. /// If memory allocation tracking is enabled, dispatch Flutter object creation.
/// ///
/// This method is not member of FlutterMemoryAllocations, because /// This method is not member of FlutterMemoryAllocations, because
/// [FlutterMemoryAllocations] should not increase size of the Flutter application /// [FlutterMemoryAllocations] should not increase size of the Flutter application
/// if memory allocations are disabled. /// if memory allocations are disabled.
/// ///
/// Should be called only from within an assert. /// The [flutterLibrary] argument is the name of the Flutter library where
/// the object is declared. For example, 'widgets' for widgets.dart.
///
/// Should be called only from within an assert and only inside Flutter Framework.
/// ///
/// Returns true to make it easier to be wrapped into `assert`. /// Returns true to make it easier to be wrapped into `assert`.
bool debugMaybeDispatchObjectCreated(String library, String className, Object object) { bool debugMaybeDispatchCreated(String flutterLibrary, String className, Object object) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated( FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: library, library: 'package:flutter/$flutterLibrary.dart',
className: className, className: className,
object: object, object: object,
); );
@ -159,7 +162,7 @@ bool debugMaybeDispatchObjectCreated(String library, String className, Object ob
/// Should be called only from within an assert. /// Should be called only from within an assert.
/// ///
/// Returns true to make it easier to be wrapped into `assert`. /// Returns true to make it easier to be wrapped into `assert`.
bool debugMaybeDispatchObjectDisposed(Object object) { bool debugMaybeDispatchDisposed(Object object) {
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: object); FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: object);
} }

View File

@ -66,8 +66,8 @@ void main() {
FlutterMemoryAllocations.instance.removeListener(listener); FlutterMemoryAllocations.instance.removeListener(listener);
}); });
test('debugMaybeDispatchObjectCreated', () async { test('debugMaybeDispatchCreated', () async {
debugMaybeDispatchObjectCreated('library', 'class', object); debugMaybeDispatchCreated('library', 'class', object);
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
final ObjectEvent? theEvent = dispatchedEvent; final ObjectEvent? theEvent = dispatchedEvent;
@ -77,15 +77,15 @@ void main() {
} }
expect(theEvent.object, object); expect(theEvent.object, object);
expect(theEvent.library, 'library'); expect(theEvent.library, 'package:flutter/library.dart');
expect(theEvent.className, 'class'); expect(theEvent.className, 'class');
} else { } else {
expect(dispatchedEvent, isNull); expect(dispatchedEvent, isNull);
} }
}); });
test('debugMaybeDispatchObjectDisposed', () async { test('debugMaybeDispatchDisposed', () async {
debugMaybeDispatchObjectDisposed(object); debugMaybeDispatchDisposed(object);
if (kFlutterMemoryAllocationsEnabled) { if (kFlutterMemoryAllocationsEnabled) {
final ObjectEvent? theEvent = dispatchedEvent; final ObjectEvent? theEvent = dispatchedEvent;