Commit 20063c5e authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Improve documentation (#6694)

Based on P5's experience
parent 5a27f6a2
...@@ -214,6 +214,8 @@ class AppBar extends StatelessWidget { ...@@ -214,6 +214,8 @@ class AppBar extends StatelessWidget {
/// The z-coordinate at which to place this app bar. /// The z-coordinate at which to place this app bar.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 4, the appropriate elevation for app bars.
final int elevation; final int elevation;
/// The color to use for the app bar's material. Typically this should be set /// The color to use for the app bar's material. Typically this should be set
......
...@@ -158,11 +158,15 @@ class MaterialButton extends StatefulWidget { ...@@ -158,11 +158,15 @@ class MaterialButton extends StatefulWidget {
/// The z-coordinate at which to place this button. /// The z-coordinate at which to place this button.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 0.
final int elevation; final int elevation;
/// The z-coordinate at which to place this button when highlighted. /// The z-coordinate at which to place this button when highlighted.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 0.
final int highlightElevation; final int highlightElevation;
/// The smallest horizontal extent that the button will occupy. /// The smallest horizontal extent that the button will occupy.
......
...@@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart';
import 'material.dart'; import 'material.dart';
/// A material design card. /// A material design card. A card has slightly rounded corners and a shadow.
/// ///
/// A card is a sheet of [Material] used to represent some related information, /// A card is a sheet of [Material] used to represent some related information,
/// for example an album, a geographical location, a meal, contact details, etc. /// for example an album, a geographical location, a meal, contact details, etc.
...@@ -33,7 +33,11 @@ class Card extends StatelessWidget { ...@@ -33,7 +33,11 @@ class Card extends StatelessWidget {
/// The color of material used for this card. /// The color of material used for this card.
final Color color; final Color color;
/// The z-coordinate at which to place this card.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 2, the appropriate elevation for cards.
final int elevation; final int elevation;
@override @override
......
...@@ -61,6 +61,8 @@ class Drawer extends StatelessWidget { ...@@ -61,6 +61,8 @@ class Drawer extends StatelessWidget {
/// The z-coordinate at which to place this drawer. /// The z-coordinate at which to place this drawer.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 16, the appropriate elevation for drawers.
final int elevation; final int elevation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
......
...@@ -336,7 +336,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> { ...@@ -336,7 +336,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
/// The type `T` is the type of the value the entry represents. All the entries /// The type `T` is the type of the value the entry represents. All the entries
/// in a given menu must represent values with consistent types. /// in a given menu must represent values with consistent types.
class DropdownMenuItem<T> extends StatelessWidget { class DropdownMenuItem<T> extends StatelessWidget {
/// Creates an item for a drop down menu. /// Creates an item for a dropdown menu.
/// ///
/// The [child] argument is required. /// The [child] argument is required.
DropdownMenuItem({ DropdownMenuItem({
...@@ -407,7 +407,7 @@ class DropdownButtonHideUnderline extends InheritedWidget { ...@@ -407,7 +407,7 @@ class DropdownButtonHideUnderline extends InheritedWidget {
/// * [FlatButton] /// * [FlatButton]
/// * <https://material.google.com/components/buttons.html#buttons-dropdown-buttons> /// * <https://material.google.com/components/buttons.html#buttons-dropdown-buttons>
class DropdownButton<T> extends StatefulWidget { class DropdownButton<T> extends StatefulWidget {
/// Creates a drop down button. /// Creates a dropdown button.
/// ///
/// The [items] must have distinct values and [value] must be among them. /// The [items] must have distinct values and [value] must be among them.
/// ///
...@@ -438,9 +438,11 @@ class DropdownButton<T> extends StatefulWidget { ...@@ -438,9 +438,11 @@ class DropdownButton<T> extends StatefulWidget {
/// The z-coordinate at which to place the menu when open. /// The z-coordinate at which to place the menu when open.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 8, the appropriate elevation for dropdown buttons.
final int elevation; final int elevation;
/// The text style to use for text in the drop down button and the drop down /// The text style to use for text in the dropdown button and the dropdown
/// menu that appears when you tap the button. /// menu that appears when you tap the button.
/// ///
/// Defaults to the [TextTheme.subhead] value of the current /// Defaults to the [TextTheme.subhead] value of the current
......
...@@ -81,9 +81,16 @@ class FloatingActionButton extends StatefulWidget { ...@@ -81,9 +81,16 @@ class FloatingActionButton extends StatefulWidget {
/// The z-coordinate at which to place this button. /// The z-coordinate at which to place this button.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 6, the appropriate elevation for floating action buttons.
final int elevation; final int elevation;
/// The z-coordinate at which to place this button when the user is touching the button. /// The z-coordinate at which to place this button when the user is touching the button.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 12, the appropriate elevation for floating action buttons
/// while they are being touched.
final int highlightElevation; final int highlightElevation;
/// Controls the size of this button. /// Controls the size of this button.
......
...@@ -9,24 +9,29 @@ import 'debug.dart'; ...@@ -9,24 +9,29 @@ import 'debug.dart';
import 'ink_well.dart'; import 'ink_well.dart';
import 'theme.dart'; import 'theme.dart';
/// An item in a material design list, typically consisting of an icon and some /// A single row typically containing an icon and some text.
/// text.
/// ///
/// [MaterialList] items are one to three lines of text optionally flanked by /// List items are one to three lines of text optionally flanked by icons or
/// icons. Icons are defined with the [leading] and [trailing] parameters. The /// other widgets, such as check boxes. The icons (or other widgets) for the
/// first line of text is not optional and is specified with [title]. The value /// item are defined with the [leading] and [trailing] parameters. The first
/// of [subtitle] will occupy the space allocated for an aditional line of text, /// line of text is not optional and is specified with [title]. The value of
/// or two lines if [isThreeLine] is true. If [dense] is true then the overall /// [subtitle], which _is_ optional, will occupy the space allocated for an
/// height of this list item and the size of the [DefaultTextStyle]s that wrap /// additional line of text, or two lines if [isThreeLine] is true. If [dense]
/// the [title] and [subtitle] widget are reduced. /// is true then the overall height of this list item and the size of the
/// [DefaultTextStyle]s that wrap the [title] and [subtitle] widget are reduced.
///
/// List items are typically used in [MaterialList]s or in [Card]s.
/// ///
/// Requires one of its ancestors to be a [Material] widget. /// Requires one of its ancestors to be a [Material] widget.
/// ///
/// See also: /// See also:
/// ///
/// * [MaterialList] /// * [MaterialList], which takes a list of [ListItem] widgets and shows them
/// * [CircleAvatar] /// as a scrolling list.
/// * [Divider] /// * [Card], which can be used with [Column] to show a few [ListItem]s.
/// * [CircleAvatar], which shows an icon representing a person.
/// * [Divider], which can be used to separate [ListItem]s.
/// * [ListItem.divideItems], another way to separate [ListItem]s.
/// * <https://material.google.com/components/lists.html> /// * <https://material.google.com/components/lists.html>
class ListItem extends StatelessWidget { class ListItem extends StatelessWidget {
/// Creates a list item. /// Creates a list item.
......
...@@ -190,6 +190,8 @@ class Material extends StatefulWidget { ...@@ -190,6 +190,8 @@ class Material extends StatefulWidget {
/// The z-coordinate at which to place this material. /// The z-coordinate at which to place this material.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 0.
final int elevation; final int elevation;
/// The color to paint the material. /// The color to paint the material.
......
...@@ -87,6 +87,11 @@ class MaterialGap extends MergeableMaterialItem { ...@@ -87,6 +87,11 @@ class MaterialGap extends MergeableMaterialItem {
/// ///
/// When a new slice is added or removed, the app is responsible for animating /// When a new slice is added or removed, the app is responsible for animating
/// the transition of the slices, while the gaps will be animated automatically. /// the transition of the slices, while the gaps will be animated automatically.
///
/// See also:
///
/// * [Card], a piece of material that does not support splitting and merging
/// but otherwise looks the same.
class MergeableMaterial extends StatefulWidget { class MergeableMaterial extends StatefulWidget {
/// Creates a mergeable Material list of items. /// Creates a mergeable Material list of items.
MergeableMaterial({ MergeableMaterial({
...@@ -103,7 +108,11 @@ class MergeableMaterial extends StatefulWidget { ...@@ -103,7 +108,11 @@ class MergeableMaterial extends StatefulWidget {
/// The main layout axis. /// The main layout axis.
final Axis mainAxis; final Axis mainAxis;
/// The elevation of all the [Material] slices. /// The z-coordinate at which to place all the [Material] slices.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 2, the appropriate elevation for cards.
final int elevation; final int elevation;
/// Whether connected pieces of [MaterialSlice] have dividers between them. /// Whether connected pieces of [MaterialSlice] have dividers between them.
......
...@@ -424,11 +424,19 @@ class _PopupMenuRoute<T> extends PopupRoute<T> { ...@@ -424,11 +424,19 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
} }
} }
/// Show a popup menu that contains the [items] at [position]. If [initialValue] /// Show a popup menu that contains the `items` at `position`. If `initialValue`
/// is specified then the first item with a matching value will be highlighted /// is specified then the first item with a matching value will be highlighted
/// and the value of [position] implies where the left, center point of the /// and the value of `position` implies where the left, center point of the
/// highlighted item should appear. If [initialValue] is not specified then position /// highlighted item should appear. If `initialValue` is not specified then
/// implies the menu's origin. /// `position` specifies the menu's origin.
///
/// The `context` argument is used to look up a [Navigator] to show the menu and
/// a [Theme] to use for the menu.
///
/// The `elevation` argument specifies the z-coordinate at which to place the
/// menu. The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9,
/// 12, 16, 24. The elevation defaults to 8, the appropriate elevation for popup
/// menus.
Future<dynamic/*=T*/> showMenu/*<T>*/({ Future<dynamic/*=T*/> showMenu/*<T>*/({
BuildContext context, BuildContext context,
RelativeRect position, RelativeRect position,
......
...@@ -74,16 +74,23 @@ class RaisedButton extends StatelessWidget { ...@@ -74,16 +74,23 @@ class RaisedButton extends StatelessWidget {
/// The z-coordinate at which to place this button. /// The z-coordinate at which to place this button.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 2, the appropriate elevation for raised buttons.
final int elevation; final int elevation;
/// The z-coordinate at which to place this button when highlighted. /// The z-coordinate at which to place this button when highlighted.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 8, the appropriate elevation for raised buttons while they are
/// being touched.
final int highlightElevation; final int highlightElevation;
/// The z-coordinate at which to place this button when disabled. /// The z-coordinate at which to place this button when disabled.
/// ///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
///
/// Defaults to 0, the appropriate elevation for disabled raised buttons.
final int disabledElevation; final int disabledElevation;
/// The theme brightness to use for this button. /// The theme brightness to use for this button.
......
...@@ -27,10 +27,10 @@ import 'virtual_viewport.dart'; ...@@ -27,10 +27,10 @@ import 'virtual_viewport.dart';
/// ///
/// See also: /// See also:
/// ///
/// * [Block]. /// * [Block], which allows its children to have arbitrary sizes.
/// * [ScrollableLazyList]. /// * [ScrollableLazyList], a more efficient version of [ScrollableList].
/// * [LazyBlock]. /// * [LazyBlock], a more efficient version of [Block].
/// * [ScrollableViewport]. /// * [ScrollableViewport], which only has one child.
class ScrollableList extends StatelessWidget { class ScrollableList extends StatelessWidget {
/// Creats a scrollable list of children that have equal size. /// Creats a scrollable list of children that have equal size.
/// ///
......
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