ScrollDragController should dispatch creation and disposal events. (#138800)
This commit is contained in:
committed by
GitHub
parent
678413542c
commit
6d4d012397
@@ -261,7 +261,17 @@ class ScrollDragController implements Drag {
|
||||
_retainMomentum = carriedVelocity != null && carriedVelocity != 0.0,
|
||||
_lastNonStationaryTimestamp = details.sourceTimeStamp,
|
||||
_kind = details.kind,
|
||||
_offsetSinceLastStop = motionStartDistanceThreshold == null ? null : 0.0;
|
||||
_offsetSinceLastStop = motionStartDistanceThreshold == null ? null : 0.0 {
|
||||
// TODO(polina-c): stop duplicating code across disposables
|
||||
// https://github.com/flutter/flutter/issues/137435
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectCreated(
|
||||
library: 'package:flutter/widgets.dart',
|
||||
className: '$ScrollDragController',
|
||||
object: this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The object that will actuate the scroll view as the user drags.
|
||||
ScrollActivityDelegate get delegate => _delegate;
|
||||
@@ -437,6 +447,11 @@ class ScrollDragController implements Drag {
|
||||
/// Called by the delegate when it is no longer sending events to this object.
|
||||
@mustCallSuper
|
||||
void dispose() {
|
||||
// TODO(polina-c): stop duplicating code across disposables
|
||||
// https://github.com/flutter/flutter/issues/137435
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
_lastDetails = null;
|
||||
onDragCanceled?.call();
|
||||
}
|
||||
|
||||
@@ -222,6 +222,19 @@ void main() {
|
||||
areCreateAndDispose,
|
||||
);
|
||||
});
|
||||
|
||||
test('$ScrollDragController dispatches memory events', () async {
|
||||
await expectLater(
|
||||
await memoryEvents(
|
||||
() => ScrollDragController(
|
||||
delegate: _ScrollActivityDelegate(),
|
||||
details: DragStartDetails(),
|
||||
).dispose(),
|
||||
ScrollDragController,
|
||||
),
|
||||
areCreateAndDispose,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class PageView62209 extends StatefulWidget {
|
||||
|
||||
Reference in New Issue
Block a user