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
This commit is contained in:
@@ -776,13 +776,74 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
/// [ScaffoldState.showSnackBar] and [ScaffoldState.showBottomSheet] functions.
|
||||
///
|
||||
/// {@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.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```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.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```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
|
||||
/// [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
|
||||
/// [FloatingActionButtonLocation.centerDocked]. The [FloatingActionButton] is
|
||||
/// connected to a callback that increments a counter.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// int _count = 0;
|
||||
///
|
||||
@@ -795,6 +856,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
/// child: Text('You have pressed the button $_count times.'),
|
||||
/// ),
|
||||
/// bottomNavigationBar: BottomAppBar(
|
||||
/// shape: const CircularNotchedRectangle(),
|
||||
/// child: Container(height: 50.0,),
|
||||
/// ),
|
||||
/// floatingActionButton: FloatingActionButton(
|
||||
|
||||
@@ -175,6 +175,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
|
||||
/// [InputDecoration] surrounds the field in a border using [OutlineInputBorder]
|
||||
/// and adds a label.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// TextField(
|
||||
/// obscureText: true,
|
||||
|
||||
@@ -3028,6 +3028,8 @@ class ListBody extends MultiChildRenderObjectWidget {
|
||||
///
|
||||
/// Using a [Stack] you can position widgets over one another.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Stack(
|
||||
/// children: <Widget>[
|
||||
@@ -3056,6 +3058,8 @@ class ListBody extends MultiChildRenderObjectWidget {
|
||||
/// This example shows how [Stack] can be used to enhance text visibility
|
||||
/// by adding gradient backdrops.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// SizedBox(
|
||||
/// width: 250,
|
||||
@@ -3880,6 +3884,8 @@ class Flex extends MultiChildRenderObjectWidget {
|
||||
/// places text centered in the first two cells and the Flutter logo centered in
|
||||
/// the third:
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Row(
|
||||
/// children: <Widget>[
|
||||
@@ -3912,8 +3918,6 @@ class Flex extends MultiChildRenderObjectWidget {
|
||||
/// 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.
|
||||
///
|
||||
/// {@tool sample}
|
||||
///
|
||||
/// #### Story time
|
||||
///
|
||||
/// Suppose, for instance, that you had this code:
|
||||
@@ -3927,7 +3931,10 @@ class Flex extends MultiChildRenderObjectWidget {
|
||||
/// ],
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// You will see this issue when you run the app:
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// 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
|
||||
@@ -3945,6 +3952,8 @@ class Flex extends MultiChildRenderObjectWidget {
|
||||
/// 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:
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Row(
|
||||
/// children: <Widget>[
|
||||
@@ -4068,6 +4077,8 @@ class Row extends Flex {
|
||||
/// This example uses a [Column] to arrange three widgets vertically, the last
|
||||
/// being made to fill all the remaining space.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Column(
|
||||
/// children: <Widget>[
|
||||
@@ -4091,6 +4102,8 @@ class Row extends Flex {
|
||||
/// [mainAxisSize] is set to [MainAxisSize.min], so that the column shrinks to
|
||||
/// fit the children.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Column(
|
||||
/// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -207,6 +207,31 @@ typedef ImageLoadingBuilder = Widget Function(
|
||||
/// The image is painted using [paintImage], which describes the meanings of the
|
||||
/// 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.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```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.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Image.network('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg')
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Icon], which shows an image from a font.
|
||||
|
||||
@@ -181,6 +181,13 @@ class DefaultTextStyle extends InheritedWidget {
|
||||
///
|
||||
/// {@tool sample}
|
||||
///
|
||||
/// This example shows how to display text using the [Text] widget. If the text
|
||||
/// overflows, it truncates the text with an ellipsis.
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// Text(
|
||||
/// 'Hello, $_name! How are you?',
|
||||
@@ -198,6 +205,8 @@ class DefaultTextStyle extends InheritedWidget {
|
||||
///
|
||||
/// {@tool sample}
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// const Text.rich(
|
||||
/// TextSpan(
|
||||
|
||||
Reference in New Issue
Block a user