From b7807ce84c71933cf2b3083f4f927e321c6f61c4 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 9 Feb 2019 01:44:38 +0530 Subject: [PATCH] Update an IconButton sample, add RaisedButton sample (#27169) --- .../flutter/lib/src/material/icon_button.dart | 24 ++++++++--- .../lib/src/material/raised_button.dart | 40 +++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index 55cf0e5f81..49a27b6e3d 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -47,11 +47,25 @@ const double _kMinButtonSize = 48.0; /// ``` /// /// ```dart -/// Widget build(BuildContext) { -/// return IconButton( -/// icon: Icon(Icons.volume_up), -/// tooltip: 'Increase volume by 10%', -/// onPressed: () { setState(() { _volume *= 1.1; }); }, +/// Widget build(BuildContext context) { +/// return Scaffold( +/// body: Center( +/// child: Column( +/// mainAxisSize: MainAxisSize.min, +/// children: [ +/// IconButton( +/// icon: Icon(Icons.volume_up), +/// tooltip: 'Increase volume by 10', +/// onPressed: () { +/// setState(() { +/// _volume += 10; +/// }); +/// }, +/// ), +/// Text('Volume : $_volume') +/// ], +/// ), +/// ), /// ); /// } /// ``` diff --git a/packages/flutter/lib/src/material/raised_button.dart b/packages/flutter/lib/src/material/raised_button.dart index 69f0a6096c..a0ee1abc45 100644 --- a/packages/flutter/lib/src/material/raised_button.dart +++ b/packages/flutter/lib/src/material/raised_button.dart @@ -31,6 +31,46 @@ import 'theme_data.dart'; /// Raised buttons have a minimum size of 88.0 by 36.0 which can be overidden /// with [ButtonTheme]. /// +/// {@tool snippet --template=stateless_widget} +/// +/// This sample shows how to render a disabled RaisedButton, an enabled RaisedButton +/// and lastly a RaisedButton with gradient background. +/// +/// ```dart +/// Scaffold( +/// body: Center( +/// child: Column( +/// mainAxisSize: MainAxisSize.min, +/// children: [ +/// RaisedButton( +/// onPressed: null, +/// child: const Text('Disabled Button'), +/// ), +/// RaisedButton( +/// onPressed: () {}, +/// child: const Text('Enabled Button'), +/// ), +/// RaisedButton( +/// onPressed: () {}, +/// textColor: Colors.white, +/// padding: const EdgeInsets.all(0.0), +/// child: Container( +/// decoration: const BoxDecoration( +/// gradient: LinearGradient( +/// colors: [Colors.red, Colors.green, Colors.blue], +/// ), +/// ), +/// padding: const EdgeInsets.all(10.0), +/// child: Text('Gradient Button'), +/// ), +/// ), +/// ], +/// ), +/// ), +/// ) +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [FlatButton], a material design button without a shadow.