From ee3db6e61a17ecc59654b70db8af3c5e569e9a7e Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 17 May 2016 12:27:13 -0700 Subject: [PATCH] Tweaks (#3975) * ScrollableBuilder tweaks --- .../flutter/lib/src/widgets/lazy_block.dart | 4 ++++ .../flutter/lib/src/widgets/scrollable.dart | 17 +++++++++++------ .../lib/src/widgets/scrollable_grid.dart | 4 ++++ .../lib/src/widgets/scrollable_list.dart | 18 ++++++++---------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/flutter/lib/src/widgets/lazy_block.dart b/packages/flutter/lib/src/widgets/lazy_block.dart index 3ded7738d7..62d423202e 100644 --- a/packages/flutter/lib/src/widgets/lazy_block.dart +++ b/packages/flutter/lib/src/widgets/lazy_block.dart @@ -144,6 +144,10 @@ class LazyBlock extends StatelessWidget { this.delegate }) : super(key: key); + // Warning: keep the dartdoc comments that follow in sync with the copies in + // Scrollable, ScrollableGrid, ScrollableViewport, ScrollableList, and + // ScrollableLazyList. And see: https://github.com/dart-lang/dartdoc/issues/1161. + /// The scroll offset this widget should use when first created. final double initialScrollOffset; diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index d637cec47e..80a7ae0a42 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -51,6 +51,10 @@ class Scrollable extends StatefulWidget { assert(scrollAnchor == ViewportAnchor.start || scrollAnchor == ViewportAnchor.end); } + // Warning: keep the dartdoc comments that follow in sync with the copies in + // ScrollableViewport, LazyBlock, ScrollableLazyList, ScrollableList, and + // ScrollableGrid. And see: https://github.com/dart-lang/dartdoc/issues/1161. + /// The scroll offset this widget should use when first created. final double initialScrollOffset; @@ -616,6 +620,8 @@ class ScrollableState extends State { return const {}; } + /// Calls the widget's [builder] by default. + /// /// Subclasses can override this function to build the interior of their /// scrollable widget. Scrollable wraps the returned widget in a /// [GestureDetector] to observe the user's interaction with this widget and @@ -633,7 +639,7 @@ class ScrollableState extends State { /// necessary, and then to call [updateGestureDetector] to update /// the gesture detectors accordingly. Widget buildContent(BuildContext context) { - // TBD: if config.builder is null throw a sensible error. + assert(config.builder != null); return config.builder(context, this); } } @@ -681,6 +687,10 @@ class ScrollableViewport extends StatefulWidget { this.child }) : super(key: key); + // Warning: keep the dartdoc comments that follow in sync with the copies in + // Scrollable, LazyBlock, ScrollableLazyList, ScrollableList, and + // ScrollableGrid. And see: https://github.com/dart-lang/dartdoc/issues/1161. + /// The scroll offset this widget should use when first created. final double initialScrollOffset; @@ -707,11 +717,6 @@ class ScrollableViewport extends StatefulWidget { /// highest index) will be pushed down, while in the /// [ViewportAnchor.end] case the items before it (with lower /// indices, up to the item with the index 0) will be pushed up. - /// - /// Subclasses may ignore this value if, for instance, they do not - /// have a concept of an anchor, or have more complicated behavior - /// (e.g. they would by default put the middle item in the middle of - /// the container). final ViewportAnchor scrollAnchor; /// Called whenever this widget starts to scroll. diff --git a/packages/flutter/lib/src/widgets/scrollable_grid.dart b/packages/flutter/lib/src/widgets/scrollable_grid.dart index a0eacdf2e8..7cc199c20e 100644 --- a/packages/flutter/lib/src/widgets/scrollable_grid.dart +++ b/packages/flutter/lib/src/widgets/scrollable_grid.dart @@ -27,6 +27,10 @@ class ScrollableGrid extends StatelessWidget { this.children }) : super(key: key); + // Warning: keep the dartdoc comments that follow in sync with the copies in + // Scrollable, LazyBlock, ScrollableViewport, ScrollableList, and + // ScrollableLazyList. And see: https://github.com/dart-lang/dartdoc/issues/1161. + /// The scroll offset this widget should use when first created. final double initialScrollOffset; diff --git a/packages/flutter/lib/src/widgets/scrollable_list.dart b/packages/flutter/lib/src/widgets/scrollable_list.dart index 8a15100be9..b4b9ea2c4d 100644 --- a/packages/flutter/lib/src/widgets/scrollable_list.dart +++ b/packages/flutter/lib/src/widgets/scrollable_list.dart @@ -64,6 +64,10 @@ class ScrollableList extends StatelessWidget { assert(itemExtent != null); } + // Warning: keep the dartdoc comments that follow in sync with the copies in + // Scrollable, LazyBlock, ScrollableLazyList, ScrollableViewport, and + // ScrollableGrid. And see: https://github.com/dart-lang/dartdoc/issues/1161. + /// The scroll offset this widget should use when first created. final double initialScrollOffset; @@ -90,11 +94,6 @@ class ScrollableList extends StatelessWidget { /// highest index) will be pushed down, while in the /// [ViewportAnchor.end] case the items before it (with lower /// indices, up to the item with the index 0) will be pushed up. - /// - /// Subclasses may ignore this value if, for instance, they do not - /// have a concept of an anchor, or have more complicated behavior - /// (e.g. they would by default put the middle item in the middle of - /// the container). final ViewportAnchor scrollAnchor; /// Called whenever this widget starts to scroll. @@ -399,6 +398,10 @@ class ScrollableLazyList extends StatelessWidget { assert(itemCount != null || scrollAnchor == ViewportAnchor.start); } + // Warning: keep the dartdoc comments that follow in sync with the copies in + // Scrollable, LazyBlock, ScrollableViewport, ScrollableList, and + // ScrollableGrid. And see: https://github.com/dart-lang/dartdoc/issues/1161. + /// The scroll offset this widget should use when first created. final double initialScrollOffset; @@ -425,11 +428,6 @@ class ScrollableLazyList extends StatelessWidget { /// highest index) will be pushed down, while in the /// [ViewportAnchor.end] case the items before it (with lower /// indices, up to the item with the index 0) will be pushed up. - /// - /// Subclasses may ignore this value if, for instance, they do not - /// have a concept of an anchor, or have more complicated behavior - /// (e.g. they would by default put the middle item in the middle of - /// the container). final ViewportAnchor scrollAnchor; /// Called whenever this widget starts to scroll.