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