From aa9aaf2eb7fd7b42b3accbe6bf43412a6ffe0e0a Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 20 Sep 2016 15:13:50 -0700 Subject: [PATCH] Restore Flutter gallery license page scrolling (#5934) --- examples/flutter_gallery/README.md | 5 +++ .../flutter/lib/src/widgets/lazy_block.dart | 1 + .../flutter/test/widget/lazy_block_test.dart | 35 ++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/examples/flutter_gallery/README.md b/examples/flutter_gallery/README.md index 31254e8db0..2f6e9e744b 100644 --- a/examples/flutter_gallery/README.md +++ b/examples/flutter_gallery/README.md @@ -20,6 +20,11 @@ the [Flutter Setup](https://flutter.io/setup/) guide. The `flutter run --release` command both builds and installs the Flutter app. +## Prerelease checklist + +* Verify that the About box's license page scrolls and reveals its long +long stream of license texts. + ## Icon Android launcher icons were generated using Android Asset Studio: diff --git a/packages/flutter/lib/src/widgets/lazy_block.dart b/packages/flutter/lib/src/widgets/lazy_block.dart index a6d6520c68..0ac21ccc4c 100644 --- a/packages/flutter/lib/src/widgets/lazy_block.dart +++ b/packages/flutter/lib/src/widgets/lazy_block.dart @@ -272,6 +272,7 @@ class LazyBlock extends StatelessWidget { minScrollOffset: minScrollOffset, scrollOffset: state.scrollOffset )); + state.updateGestureDetector(); }, delegate: delegate ); diff --git a/packages/flutter/test/widget/lazy_block_test.dart b/packages/flutter/test/widget/lazy_block_test.dart index fcf5064e05..f5cd7b4c31 100644 --- a/packages/flutter/test/widget/lazy_block_test.dart +++ b/packages/flutter/test/widget/lazy_block_test.dart @@ -53,7 +53,7 @@ void main() { }); - testWidgets('Underflowing LazyBlock contentExtent should track additional children ', (WidgetTester tester) async { + testWidgets('Underflowing LazyBlock contentExtent should track additional children', (WidgetTester tester) async { await tester.pumpWidget(new LazyBlock( delegate: new LazyBlockChildren( children: [ @@ -155,4 +155,37 @@ void main() { expect(scrollBehavior.contentExtent, equals(700.0)); }); + testWidgets('Overflowing LazyBlock should become scrollable', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/5920 + // When a LazyBlock's viewport hasn't overflowed, scrolling is disabled. + // When children are added that cause it to overflow, scrolling should + // be enabled. + + await tester.pumpWidget(new LazyBlock( + delegate: new LazyBlockChildren( + children: [ + new SizedBox(height: 100.0, child: new Text('100')), + ] + ) + )); + + StatefulElement statefulElement = tester.element(find.byType(Scrollable)); + ScrollableState scrollable = statefulElement.state; + OverscrollWhenScrollableBehavior scrollBehavior = scrollable.scrollBehavior; + expect(scrollBehavior.isScrollable, isFalse); + + await tester.pumpWidget(new LazyBlock( + delegate: new LazyBlockChildren( + children: [ + new SizedBox(height: 100.0, child: new Text('100')), + new SizedBox(height: 200.0, child: new Text('200')), + new SizedBox(height: 400.0, child: new Text('400')), + ] + ) + )); + + expect(scrollBehavior.isScrollable, isTrue); + }); + + }