From 665fff00c7ae71967ce80c63bf3dda87b71c1c27 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Mon, 12 Nov 2018 08:54:08 -0800 Subject: [PATCH] Update Scaffold docs and example code (#24159) Upgraded Scaffold example to an application example. --- .../flutter/lib/src/material/scaffold.dart | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 1741cb21d2..ef8ee4492c 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -657,32 +657,39 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr /// [ScaffoldState] for the current [BuildContext] via [Scaffold.of] and use the /// [ScaffoldState.showSnackBar] and [ScaffoldState.showBottomSheet] functions. /// -/// {@tool sample} +/// {@tool snippet --template=stateful_widget} /// -/// 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 centered and docked within the -/// [BottomAppBar] using [FloatingActionButtonLocation.centerDocked]. +/// 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 +/// centered and docked within the [BottomAppBar] using +/// [FloatingActionButtonLocation.centerDocked]. The [FloatingActionButton] is +/// connected to a callback that increments a counter. /// /// ```dart -/// Scaffold( -/// appBar: AppBar( -/// title: Text('Sample Code'), -/// ), -/// body: Center( -/// child: Text('Scaffold'), -/// ), -/// bottomNavigationBar: BottomAppBar( -/// child: Container(height: 50.0,), -/// ), -/// floatingActionButton: FloatingActionButton( -/// onPressed: () {}, -/// tooltip: 'Increment', -/// child: Icon(Icons.add), -/// ), -/// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, -/// ) +/// int _count = 0; +/// +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// title: Text('Sample Code'), +/// ), +/// body: Center( +/// child: Text('You have pressed the button $_count times.'), +/// ), +/// bottomNavigationBar: BottomAppBar( +/// child: Container(height: 50.0,), +/// ), +/// floatingActionButton: FloatingActionButton( +/// onPressed: () => setState(() { +/// _count++; +/// }), +/// tooltip: 'Increment Counter', +/// child: Icon(Icons.add), +/// ), +/// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, +/// ); +/// } /// ``` /// {@end-tool} ///