Commit 4ec51444 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Scrollable should restore its viewport dimensions when it reappears (#5862)

parent 42b01132
......@@ -274,6 +274,8 @@ class ScrollableState<T extends Scrollable> extends State<T> {
Simulation _simulation; // if we're flinging, then this is the animation with which we're doing it
AnimationController _controller;
double _contentExtent;
double _containerExtent;
@override
void dispose() {
......@@ -285,7 +287,11 @@ class ScrollableState<T extends Scrollable> extends State<T> {
@override
void dependenciesChanged() {
_scrollBehavior = createScrollBehavior();
didUpdateScrollBehavior(scrollOffset);
didUpdateScrollBehavior(_scrollBehavior.updateExtents(
contentExtent: _contentExtent,
containerExtent: _containerExtent,
scrollOffset: scrollOffset
));
super.dependenciesChanged();
}
......@@ -495,6 +501,8 @@ class ScrollableState<T extends Scrollable> extends State<T> {
/// [didUpdateScrollBehavior].
/// 3. Updating this object's gesture detector with [updateGestureDetector].
void handleExtentsChanged(double contentExtent, double containerExtent) {
_contentExtent = contentExtent;
_containerExtent = containerExtent;
didUpdateScrollBehavior(scrollBehavior.updateExtents(
contentExtent: contentExtent,
containerExtent: containerExtent,
......
......@@ -80,6 +80,8 @@ void main() {
expect(delegate, isNotNull);
expect(delegate.flag, isTrue);
expect(behavior, new isInstanceOf<BoundedBehavior>());
expect(behavior.contentExtent, equals(1000.0));
expect(behavior.containerExtent, equals(600.0));
// Same Scrollable, different ScrollConfiguration
await tester.pumpWidget(
......@@ -101,5 +103,8 @@ void main() {
expect(delegate, isNotNull);
expect(delegate.flag, isFalse);
expect(behavior, new isInstanceOf<UnboundedBehavior>());
// Regression test for https://github.com/flutter/flutter/issues/5856
expect(behavior.contentExtent, equals(1000.0));
expect(behavior.containerExtent, equals(600.0));
});
}
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