ScrollActivity should dispatch creation and disposal events. (#137961)
This commit is contained in:
parent
2d9a075dfc
commit
4880aab113
@ -57,7 +57,17 @@ abstract class ScrollActivityDelegate {
|
|||||||
/// [ScrollPosition] of a [Scrollable].
|
/// [ScrollPosition] of a [Scrollable].
|
||||||
abstract class ScrollActivity {
|
abstract class ScrollActivity {
|
||||||
/// Initializes [delegate] for subclasses.
|
/// Initializes [delegate] for subclasses.
|
||||||
ScrollActivity(this._delegate);
|
ScrollActivity(this._delegate) {
|
||||||
|
// 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: '$ScrollActivity',
|
||||||
|
object: this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The delegate that this activity will use to actuate the scroll view.
|
/// The delegate that this activity will use to actuate the scroll view.
|
||||||
ScrollActivityDelegate get delegate => _delegate;
|
ScrollActivityDelegate get delegate => _delegate;
|
||||||
@ -137,6 +147,12 @@ abstract class ScrollActivity {
|
|||||||
/// Called when the scroll view stops performing this activity.
|
/// Called when the scroll view stops performing this activity.
|
||||||
@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);
|
||||||
|
}
|
||||||
|
|
||||||
_isDisposed = true;
|
_isDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +212,16 @@ void main() {
|
|||||||
expect(lastTapped, equals(3));
|
expect(lastTapped, equals(3));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('$ScrollActivity dispatches memory events', () async {
|
||||||
|
await expectLater(
|
||||||
|
await memoryEvents(
|
||||||
|
() => _ScrollActivity(_ScrollActivityDelegate()).dispose(),
|
||||||
|
_ScrollActivity,
|
||||||
|
),
|
||||||
|
areCreateAndDispose,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class PageView62209 extends StatefulWidget {
|
class PageView62209 extends StatefulWidget {
|
||||||
@ -359,3 +369,33 @@ class _Carousel62209State extends State<Carousel62209> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ScrollActivity extends ScrollActivity {
|
||||||
|
_ScrollActivity(super.delegate);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isScrolling => false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get shouldIgnorePointer => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
double get velocity => 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ScrollActivityDelegate extends ScrollActivityDelegate {
|
||||||
|
@override
|
||||||
|
void applyUserOffset(double delta) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AxisDirection get axisDirection => AxisDirection.down;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void goBallistic(double velocity) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void goIdle() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
double setPixels(double pixels) => 0.0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user