Unverified Commit 6d4d0123 authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

ScrollDragController should dispatch creation and disposal events. (#138800)

parent 67841354
...@@ -261,7 +261,17 @@ class ScrollDragController implements Drag { ...@@ -261,7 +261,17 @@ class ScrollDragController implements Drag {
_retainMomentum = carriedVelocity != null && carriedVelocity != 0.0, _retainMomentum = carriedVelocity != null && carriedVelocity != 0.0,
_lastNonStationaryTimestamp = details.sourceTimeStamp, _lastNonStationaryTimestamp = details.sourceTimeStamp,
_kind = details.kind, _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. /// The object that will actuate the scroll view as the user drags.
ScrollActivityDelegate get delegate => _delegate; ScrollActivityDelegate get delegate => _delegate;
...@@ -437,6 +447,11 @@ class ScrollDragController implements Drag { ...@@ -437,6 +447,11 @@ class ScrollDragController implements Drag {
/// Called by the delegate when it is no longer sending events to this object. /// Called by the delegate when it is no longer sending events to this object.
@mustCallSuper @mustCallSuper
void dispose() { 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; _lastDetails = null;
onDragCanceled?.call(); onDragCanceled?.call();
} }
......
...@@ -222,6 +222,19 @@ void main() { ...@@ -222,6 +222,19 @@ void main() {
areCreateAndDispose, areCreateAndDispose,
); );
}); });
test('$ScrollDragController dispatches memory events', () async {
await expectLater(
await memoryEvents(
() => ScrollDragController(
delegate: _ScrollActivityDelegate(),
details: DragStartDetails(),
).dispose(),
ScrollDragController,
),
areCreateAndDispose,
);
});
} }
class PageView62209 extends StatefulWidget { class PageView62209 extends StatefulWidget {
......
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