Commit 995fd27e authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

More Block doc improvements (#6481)

Mostly around pointing people towards Block more aggressively.
parent a9790222
...@@ -48,9 +48,13 @@ Map<MaterialListType, double> kListItemExtent = const <MaterialListType, double> ...@@ -48,9 +48,13 @@ Map<MaterialListType, double> kListItemExtent = const <MaterialListType, double>
/// ///
/// See also: /// See also:
/// ///
/// * [ListItem] /// * [Block], which shows heterogeneous widgets in a list and makes the list
/// * [ScrollableList] /// scrollable if necessary.
/// * [TwoLevelList] /// * [ListItem], to show content in a [MaterialList] using material design
/// conventions.
/// * [ScrollableList], on which this widget is based.
/// * [TwoLevelList], for lists that have subsections that can collapse and
/// expand.
/// * [ScrollableGrid] /// * [ScrollableGrid]
/// * <https://material.google.com/components/lists.html> /// * <https://material.google.com/components/lists.html>
class MaterialList extends StatelessWidget { class MaterialList extends StatelessWidget {
......
...@@ -255,6 +255,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> with SingleTickerProv ...@@ -255,6 +255,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> with SingleTickerProv
/// ///
/// * [TwoLevelSublist] /// * [TwoLevelSublist]
/// * [TwoLevelListItem] /// * [TwoLevelListItem]
/// * [MaterialList], for lists that only have one level.
class TwoLevelList extends StatelessWidget { class TwoLevelList extends StatelessWidget {
/// Creates a scrollable list of items that can expand and collapse. /// Creates a scrollable list of items that can expand and collapse.
/// ///
......
...@@ -1406,7 +1406,7 @@ class Viewport extends SingleChildRenderObjectWidget { ...@@ -1406,7 +1406,7 @@ class Viewport extends SingleChildRenderObjectWidget {
/// ///
/// See also: /// See also:
/// ///
/// * [Block] (which combines block layout with scrolling) /// * [Block], which combines block layout with scrolling.
class BlockBody extends MultiChildRenderObjectWidget { class BlockBody extends MultiChildRenderObjectWidget {
/// Creates a block layout widget. /// Creates a block layout widget.
/// ///
...@@ -1951,6 +1951,13 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -1951,6 +1951,13 @@ class Flex extends MultiChildRenderObjectWidget {
/// ///
/// For details about the flex layout algorithm, see [RenderFlex]. To control /// For details about the flex layout algorithm, see [RenderFlex]. To control
/// the flex of child widgets, see the [Flexible] widget. /// the flex of child widgets, see the [Flexible] widget.
///
/// The Row widget does not scroll (and in general it is considered an error to
/// have more children in a Row than will fit in the available room). If you
/// have a line of widgets and want them to be able to scroll if there is
/// insufficient room, consider using a [Block].
///
/// For a vertical variant, see [Column].
class Row extends Flex { class Row extends Flex {
/// Creates a horizontal array of children. /// Creates a horizontal array of children.
/// ///
...@@ -1984,6 +1991,8 @@ class Row extends Flex { ...@@ -1984,6 +1991,8 @@ class Row extends Flex {
/// to have more children in a Column than will fit in the available room). If /// to have more children in a Column than will fit in the available room). If
/// you have a list of widgets and want them to be able to scroll if there is /// you have a list of widgets and want them to be able to scroll if there is
/// insufficient room, consider using a [Block]. /// insufficient room, consider using a [Block].
///
/// For a horizontal variant, see [Row].
class Column extends Flex { class Column extends Flex {
/// Creates a vertical array of children. /// Creates a vertical array of children.
/// ///
......
...@@ -191,9 +191,13 @@ class LazyBlockChildren extends LazyBlockDelegate { ...@@ -191,9 +191,13 @@ class LazyBlockChildren extends LazyBlockDelegate {
/// [scrollOffset] is expensive because [LazyBlock] computes the size of every /// [scrollOffset] is expensive because [LazyBlock] computes the size of every
/// child between the old scroll offset and the new scroll offset. /// child between the old scroll offset and the new scroll offset.
/// ///
/// Prefer [ScrollableList] when all the children have the same size because /// Prefer [ScrollableLazyList] when all the children have the same size because
/// it can use that property to be more efficient. Prefer [ScrollableViewport] /// it can use that property to be more efficient. Prefer [ScrollableViewport]
/// when there is only one child. /// when there is only one child.
///
/// Consider [Block] if you have a small number of children that will only
/// scroll in unusual circumstances (e.g. when the user's device is smaller than
/// expected).
class LazyBlock extends StatelessWidget { class LazyBlock extends StatelessWidget {
/// Creates an infinite scrolling list of variable height children. /// Creates an infinite scrolling list of variable height children.
/// ///
......
...@@ -61,14 +61,14 @@ typedef double SnapOffsetCallback(double scrollOffset, Size containerSize); ...@@ -61,14 +61,14 @@ typedef double SnapOffsetCallback(double scrollOffset, Size containerSize);
/// A base class for scrollable widgets. /// A base class for scrollable widgets.
/// ///
/// If you have a list of widgets and want them to be able to scroll if there is
/// insufficient room, consider using [Block].
///
/// Commonly used classes that are based on Scrollable include [ScrollableList], /// Commonly used classes that are based on Scrollable include [ScrollableList],
/// [ScrollableGrid], and [ScrollableViewport]. /// [ScrollableGrid], and [ScrollableViewport].
/// ///
/// Widgets that subclass [Scrollable] typically use state objects that subclass /// Widgets that subclass [Scrollable] typically use state objects that subclass
/// [ScrollableState]. /// [ScrollableState].
///
/// If you have a list of widgets and want them to be able to scroll if there is
/// insufficient room, consider using [Block].
class Scrollable extends StatefulWidget { class Scrollable extends StatefulWidget {
/// Initializes fields for subclasses. /// Initializes fields for subclasses.
/// ///
...@@ -916,11 +916,11 @@ class ScrollNotification extends Notification { ...@@ -916,11 +916,11 @@ class ScrollNotification extends Notification {
/// ///
/// See also: /// See also:
/// ///
/// * [Block], if your single child is a [Column].
/// * [ScrollableList], if you have many identically-sized children. /// * [ScrollableList], if you have many identically-sized children.
/// * [PageableList], if you have children that each take the entire screen. /// * [PageableList], if you have children that each take the entire screen.
/// * [ScrollableGrid], if your children are in a grid pattern. /// * [ScrollableGrid], if your children are in a grid pattern.
/// * [LazyBlock], if you have many children of varying sizes. /// * [LazyBlock], if you have many children of varying sizes.
/// * [Block], if your single child is a [BlockBody] or a [Column].
class ScrollableViewport extends StatelessWidget { class ScrollableViewport extends StatelessWidget {
/// Creates a simple scrolling widget that has a single child. /// Creates a simple scrolling widget that has a single child.
/// ///
...@@ -1050,9 +1050,9 @@ class ScrollableViewport extends StatelessWidget { ...@@ -1050,9 +1050,9 @@ class ScrollableViewport extends StatelessWidget {
/// ///
/// See also: /// See also:
/// ///
/// * [ScrollableViewport], if you only have one child. /// * [LazyBlock], if you have many children with varying heights.
/// * [ScrollableList], if all your children are the same height. /// * [ScrollableList], if all your children are the same height.
/// * [LazyBlock], if you have children with varying heights. /// * [ScrollableViewport], if you only have one child.
class Block extends StatelessWidget { class Block extends StatelessWidget {
/// Creates a scrollable array of children. /// Creates a scrollable array of children.
Block({ Block({
......
...@@ -18,14 +18,16 @@ import 'virtual_viewport.dart'; ...@@ -18,14 +18,16 @@ import 'virtual_viewport.dart';
/// uses an [Iterable] list of children. That makes [ScrollableList] suitable /// uses an [Iterable] list of children. That makes [ScrollableList] suitable
/// for a large (but not extremely large or infinite) list of children. /// for a large (but not extremely large or infinite) list of children.
/// ///
/// [ScrollableList] differs from [LazyBlock] in that [ScrollableList] requires /// [ScrollableList] differs from [Block] and [LazyBlock] in that
/// each of its children to be the same size. That makes [ScrollableList] more /// [ScrollableList] requires each of its children to be the same size. That
/// efficient but less flexible than [LazyBlock]. /// makes [ScrollableList] more efficient but less flexible than [Block] and
/// [LazyBlock].
/// ///
/// Prefer [ScrollableViewport] when there is only one child. /// Prefer [ScrollableViewport] when there is only one child.
/// ///
/// See also: /// See also:
/// ///
/// * [Block].
/// * [ScrollableLazyList]. /// * [ScrollableLazyList].
/// * [LazyBlock]. /// * [LazyBlock].
/// * [ScrollableViewport]. /// * [ScrollableViewport].
......
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