Unverified Commit 70b405ee authored by Brian Egan's avatar Brian Egan Committed by GitHub

Add images and update examples for top widgets: (#36460)

* Add images and update examples for top widgets:

  - scaffold
  - text field
  - image
  - text
  - row
  - column
  - stack
parent d0238c71
...@@ -776,13 +776,74 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -776,13 +776,74 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
/// [ScaffoldState.showSnackBar] and [ScaffoldState.showBottomSheet] functions. /// [ScaffoldState.showSnackBar] and [ScaffoldState.showBottomSheet] functions.
/// ///
/// {@tool snippet --template=stateful_widget_material} /// {@tool snippet --template=stateful_widget_material}
/// This example shows a [Scaffold] with a [body] and [FloatingActionButton].
/// The [body] is a [Text] placed in a [Center] in order to center the text
/// within the [Scaffold]. The [FloatingActionButton] is connected to a
/// callback that increments a counter.
///
/// ![A screenshot of the Scaffold widget with a body and floating action button](https://flutter.github.io/assets-for-api-docs/assets/material/scaffold.png)
///
/// ```dart
/// int _count = 0;
///
/// Widget build(BuildContext context) {
/// return Scaffold(
/// appBar: AppBar(
/// title: const Text('Sample Code'),
/// ),
/// body: Center(
/// child: Text('You have pressed the button $_count times.')
/// ),
/// floatingActionButton: FloatingActionButton(
/// onPressed: () => setState(() => _count++),
/// tooltip: 'Increment Counter',
/// child: const Icon(Icons.add),
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
/// {@tool snippet --template=stateful_widget_material}
/// This example shows a [Scaffold] with a [backgroundColor], [body] and
/// [FloatingActionButton]. The [body] is a [Text] placed in a [Center] in order
/// to center the text within the [Scaffold]. The [FloatingActionButton] is
/// connected to a callback that increments a counter.
///
/// ![A screenshot of the Scaffold widget example with a background color](https://flutter.github.io/assets-for-api-docs/assets/material/scaffold_background_color.png)
///
/// ```dart
/// int _count = 0;
///
/// Widget build(BuildContext context) {
/// return Scaffold(
/// appBar: AppBar(
/// title: const Text('Sample Code'),
/// ),
/// body: Center(
/// child: Text('You have pressed the button $_count times.')
/// ),
/// backgroundColor: Colors.blueGrey.shade200,
/// floatingActionButton: FloatingActionButton(
/// onPressed: () => setState(() => _count++),
/// tooltip: 'Increment Counter',
/// child: const Icon(Icons.add),
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
/// {@tool snippet --template=stateful_widget_material}
/// This example shows a [Scaffold] with an [AppBar], a [BottomAppBar] and a /// This example shows a [Scaffold] with an [AppBar], a [BottomAppBar] and a
/// [FloatingActionButton]. The [body] is a [Text] placed in a [Center] in order /// [FloatingActionButton]. The [body] is a [Text] placed in a [Center] in order
/// to center the text within the [Scaffold] and the [FloatingActionButton] is /// to center the text within the [Scaffold]. The [FloatingActionButton] is
/// centered and docked within the [BottomAppBar] using /// centered and docked within the [BottomAppBar] using
/// [FloatingActionButtonLocation.centerDocked]. The [FloatingActionButton] is /// [FloatingActionButtonLocation.centerDocked]. The [FloatingActionButton] is
/// connected to a callback that increments a counter. /// connected to a callback that increments a counter.
/// ///
/// ![A screenshot of the Scaffold widget with a bottom navigation bar and docked floating action button](https://flutter.github.io/assets-for-api-docs/assets/material/scaffold_bottom_app_bar.png)
///
/// ```dart /// ```dart
/// int _count = 0; /// int _count = 0;
/// ///
...@@ -795,6 +856,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -795,6 +856,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
/// child: Text('You have pressed the button $_count times.'), /// child: Text('You have pressed the button $_count times.'),
/// ), /// ),
/// bottomNavigationBar: BottomAppBar( /// bottomNavigationBar: BottomAppBar(
/// shape: const CircularNotchedRectangle(),
/// child: Container(height: 50.0,), /// child: Container(height: 50.0,),
/// ), /// ),
/// floatingActionButton: FloatingActionButton( /// floatingActionButton: FloatingActionButton(
......
...@@ -175,6 +175,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete ...@@ -175,6 +175,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
/// [InputDecoration] surrounds the field in a border using [OutlineInputBorder] /// [InputDecoration] surrounds the field in a border using [OutlineInputBorder]
/// and adds a label. /// and adds a label.
/// ///
/// ![A screenshot of the TextField widget](https://flutter.github.io/assets-for-api-docs/assets/material/text_field.png)
///
/// ```dart /// ```dart
/// TextField( /// TextField(
/// obscureText: true, /// obscureText: true,
......
...@@ -3028,6 +3028,8 @@ class ListBody extends MultiChildRenderObjectWidget { ...@@ -3028,6 +3028,8 @@ class ListBody extends MultiChildRenderObjectWidget {
/// ///
/// Using a [Stack] you can position widgets over one another. /// Using a [Stack] you can position widgets over one another.
/// ///
/// ![A screenshot of the Stack widget](https://flutter.github.io/assets-for-api-docs/assets/widgets/stack.png)
///
/// ```dart /// ```dart
/// Stack( /// Stack(
/// children: <Widget>[ /// children: <Widget>[
...@@ -3056,6 +3058,8 @@ class ListBody extends MultiChildRenderObjectWidget { ...@@ -3056,6 +3058,8 @@ class ListBody extends MultiChildRenderObjectWidget {
/// This example shows how [Stack] can be used to enhance text visibility /// This example shows how [Stack] can be used to enhance text visibility
/// by adding gradient backdrops. /// by adding gradient backdrops.
/// ///
/// ![A screenshot of the Stack widget using a gradient to enhance text visibility](https://flutter.github.io/assets-for-api-docs/assets/widgets/stack_with_gradient.png)
///
/// ```dart /// ```dart
/// SizedBox( /// SizedBox(
/// width: 250, /// width: 250,
...@@ -3880,6 +3884,8 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -3880,6 +3884,8 @@ class Flex extends MultiChildRenderObjectWidget {
/// places text centered in the first two cells and the Flutter logo centered in /// places text centered in the first two cells and the Flutter logo centered in
/// the third: /// the third:
/// ///
/// ![A screenshot of the Row widget](https://flutter.github.io/assets-for-api-docs/assets/widgets/row.png)
///
/// ```dart /// ```dart
/// Row( /// Row(
/// children: <Widget>[ /// children: <Widget>[
...@@ -3912,8 +3918,6 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -3912,8 +3918,6 @@ class Flex extends MultiChildRenderObjectWidget {
/// warning box on the edge that is overflowing. If there is room on the outside /// warning box on the edge that is overflowing. If there is room on the outside
/// of the row, the amount of overflow is printed in red lettering. /// of the row, the amount of overflow is printed in red lettering.
/// ///
/// {@tool sample}
///
/// #### Story time /// #### Story time
/// ///
/// Suppose, for instance, that you had this code: /// Suppose, for instance, that you had this code:
...@@ -3927,7 +3931,10 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -3927,7 +3931,10 @@ class Flex extends MultiChildRenderObjectWidget {
/// ], /// ],
/// ) /// )
/// ``` /// ```
/// {@end-tool} ///
/// You will see this issue when you run the app:
///
/// ![A screenshot of the error using the Row widget](https://flutter.github.io/assets-for-api-docs/assets/widgets/row_error.png)
/// ///
/// The row first asks its first child, the [FlutterLogo], to lay out, at /// The row first asks its first child, the [FlutterLogo], to lay out, at
/// whatever size the logo would like. The logo is friendly and happily decides /// whatever size the logo would like. The logo is friendly and happily decides
...@@ -3945,6 +3952,8 @@ class Flex extends MultiChildRenderObjectWidget { ...@@ -3945,6 +3952,8 @@ class Flex extends MultiChildRenderObjectWidget {
/// The fix is to wrap the second child in an [Expanded] widget, which tells the /// The fix is to wrap the second child in an [Expanded] widget, which tells the
/// row that the child should be given the remaining room: /// row that the child should be given the remaining room:
/// ///
/// ![A screenshot of the Row widget after applying the fix](https://flutter.github.io/assets-for-api-docs/assets/widgets/row_fixed.png)
///
/// ```dart /// ```dart
/// Row( /// Row(
/// children: <Widget>[ /// children: <Widget>[
...@@ -4068,6 +4077,8 @@ class Row extends Flex { ...@@ -4068,6 +4077,8 @@ class Row extends Flex {
/// This example uses a [Column] to arrange three widgets vertically, the last /// This example uses a [Column] to arrange three widgets vertically, the last
/// being made to fill all the remaining space. /// being made to fill all the remaining space.
/// ///
/// ![A screenshot of the Column widget](https://flutter.github.io/assets-for-api-docs/assets/widgets/column.png)
///
/// ```dart /// ```dart
/// Column( /// Column(
/// children: <Widget>[ /// children: <Widget>[
...@@ -4091,6 +4102,8 @@ class Row extends Flex { ...@@ -4091,6 +4102,8 @@ class Row extends Flex {
/// [mainAxisSize] is set to [MainAxisSize.min], so that the column shrinks to /// [mainAxisSize] is set to [MainAxisSize.min], so that the column shrinks to
/// fit the children. /// fit the children.
/// ///
/// ![A screenshot of the Column widget with a customized crossAxisAlignment and mainAxisSize](https://flutter.github.io/assets-for-api-docs/assets/widgets/column_properties.png)
///
/// ```dart /// ```dart
/// Column( /// Column(
/// crossAxisAlignment: CrossAxisAlignment.start, /// crossAxisAlignment: CrossAxisAlignment.start,
......
...@@ -207,6 +207,31 @@ typedef ImageLoadingBuilder = Widget Function( ...@@ -207,6 +207,31 @@ typedef ImageLoadingBuilder = Widget Function(
/// The image is painted using [paintImage], which describes the meanings of the /// The image is painted using [paintImage], which describes the meanings of the
/// various fields on this class in more detail. /// various fields on this class in more detail.
/// ///
/// {@tool sample}
/// The default constructor can be used with any [ImageProvider], such as a
/// [NetworkImage], to display an image from the internet.
///
/// ![An image of an owl displayed by the image widget](https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg)
///
/// ```dart
/// const Image(
/// image: NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg'),
/// )
/// ```
/// {@end-tool}
///
/// {@tool sample}
/// The [Image] Widget also provides several constructors to display different
/// types of images for convenience. In this example, use the [Image.network]
/// constructor to display an image from the internet.
///
/// ![An image of an owl displayed by the image widget using the shortcut constructor](https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg)
///
/// ```dart
/// Image.network('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg')
/// ```
/// {@end-tool}
///
/// See also: /// See also:
/// ///
/// * [Icon], which shows an image from a font. /// * [Icon], which shows an image from a font.
......
...@@ -181,6 +181,13 @@ class DefaultTextStyle extends InheritedWidget { ...@@ -181,6 +181,13 @@ class DefaultTextStyle extends InheritedWidget {
/// ///
/// {@tool sample} /// {@tool sample}
/// ///
/// This example shows how to display text using the [Text] widget. If the text
/// overflows, it truncates the text with an ellipsis.
///
/// ![A screenshot of the Text widget](https://flutter.github.io/assets-for-api-docs/assets/widgets/text.png)
///
/// ![A screenshot of the Text widget displaying an ellipsis to trim the overflowing text](https://flutter.github.io/assets-for-api-docs/assets/widgets/text_ellipsis.png)
///
/// ```dart /// ```dart
/// Text( /// Text(
/// 'Hello, $_name! How are you?', /// 'Hello, $_name! How are you?',
...@@ -198,6 +205,8 @@ class DefaultTextStyle extends InheritedWidget { ...@@ -198,6 +205,8 @@ class DefaultTextStyle extends InheritedWidget {
/// ///
/// {@tool sample} /// {@tool sample}
/// ///
/// ![A screenshot of the following rich text example](https://flutter.github.io/assets-for-api-docs/assets/widgets/text_rich.png)
///
/// ```dart /// ```dart
/// const Text.rich( /// const Text.rich(
/// TextSpan( /// TextSpan(
......
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