Unverified Commit 1a08ce74 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Updated the remaining obsolete button references in flutter_gallery (#67437)

parent 4fa4f91d
...@@ -6,23 +6,23 @@ import 'package:flutter/material.dart'; ...@@ -6,23 +6,23 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart'; import '../../gallery/demo.dart';
const String _raisedText = const String _elevatedText =
'Raised buttons add dimension to mostly flat layouts. They emphasize ' 'Elevated buttons add dimension to mostly flat layouts. They emphasize '
'functions on busy or wide spaces.'; 'functions on busy or wide spaces.';
const String _raisedCode = 'buttons_raised'; const String _elevatedCode = 'buttons_elevated';
const String _flatText = 'A flat button displays an ink splash on press ' const String _textText = 'A text button displays an ink splash on press '
'but does not lift. Use flat buttons on toolbars, in dialogs and ' 'but does not lift. Use text buttons on toolbars, in dialogs and '
'inline with padding'; 'inline with padding';
const String _flatCode = 'buttons_flat'; const String _textCode = 'buttons_text';
const String _outlineText = const String _outlinedText =
'Outline buttons become opaque and elevate when pressed. They are often ' 'Outlined buttons become opaque and elevate when pressed. They are often '
'paired with raised buttons to indicate an alternative, secondary action.'; 'paired with elevated buttons to indicate an alternative, secondary action.';
const String _outlineCode = 'buttons_outline'; const String _outlinedCode = 'buttons_outlined';
const String _dropdownText = const String _dropdownText =
"A dropdown button displays a menu that's used to select a value from a " "A dropdown button displays a menu that's used to select a value from a "
...@@ -53,44 +53,31 @@ class ButtonsDemo extends StatefulWidget { ...@@ -53,44 +53,31 @@ class ButtonsDemo extends StatefulWidget {
} }
class _ButtonsDemoState extends State<ButtonsDemo> { class _ButtonsDemoState extends State<ButtonsDemo> {
ShapeBorder _buttonShape; OutlinedBorder _buttonShape;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ButtonThemeData buttonTheme = ButtonTheme.of(context).copyWith(
shape: _buttonShape
);
final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[ final List<ComponentDemoTabData> demos = <ComponentDemoTabData>[
ComponentDemoTabData( ComponentDemoTabData(
tabName: 'RAISED', tabName: 'ELEVATED',
description: _raisedText, description: _elevatedText,
demoWidget: ButtonTheme.fromButtonThemeData( demoWidget: buildElevatedButton(_buttonShape),
data: buttonTheme, exampleCodeTag: _elevatedCode,
child: buildRaisedButton(), documentationUrl: 'https://docs.flutter.io/flutter/material/ElevatedButton-class.html',
),
exampleCodeTag: _raisedCode,
documentationUrl: 'https://docs.flutter.io/flutter/material/RaisedButton-class.html',
), ),
ComponentDemoTabData( ComponentDemoTabData(
tabName: 'FLAT', tabName: 'TEXT',
description: _flatText, description: _textText,
demoWidget: ButtonTheme.fromButtonThemeData( demoWidget: buildTextButton(_buttonShape),
data: buttonTheme, exampleCodeTag: _textCode,
child: buildFlatButton(), documentationUrl: 'https://docs.flutter.io/flutter/material/TextButton-class.html',
),
exampleCodeTag: _flatCode,
documentationUrl: 'https://docs.flutter.io/flutter/material/FlatButton-class.html',
), ),
ComponentDemoTabData( ComponentDemoTabData(
tabName: 'OUTLINE', tabName: 'OUTLINED',
description: _outlineText, description: _outlinedText,
demoWidget: ButtonTheme.fromButtonThemeData( demoWidget: buildOutlinedButton(_buttonShape),
data: buttonTheme, exampleCodeTag: _outlinedCode,
child: buildOutlineButton(), documentationUrl: 'https://docs.flutter.io/flutter/material/OutlinedButton-class.html',
),
exampleCodeTag: _outlineCode,
documentationUrl: 'https://docs.flutter.io/flutter/material/OutlineButton-class.html',
), ),
ComponentDemoTabData( ComponentDemoTabData(
tabName: 'DROPDOWN', tabName: 'DROPDOWN',
...@@ -131,7 +118,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -131,7 +118,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
); );
} }
Widget buildRaisedButton() { Widget buildElevatedButton(OutlinedBorder shape) {
final ButtonStyle style = ElevatedButton.styleFrom(shape: shape);
return Align( return Align(
alignment: const Alignment(0.0, -0.2), alignment: const Alignment(0.0, -0.2),
child: Column( child: Column(
...@@ -140,13 +128,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -140,13 +128,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
ButtonBar( ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
RaisedButton( ElevatedButton(
child: const Text('RAISED BUTTON', semanticsLabel: 'RAISED BUTTON 1'), style: style,
child: const Text('ELEVATED BUTTON', semanticsLabel: 'ELEVATED BUTTON 1'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
const RaisedButton( const ElevatedButton(
child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 1'), child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 1'),
onPressed: null, onPressed: null,
), ),
...@@ -155,14 +144,16 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -155,14 +144,16 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
ButtonBar( ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
RaisedButton.icon( ElevatedButton.icon(
style: style,
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('RAISED BUTTON', semanticsLabel: 'RAISED BUTTON 2'), label: const Text('ELEVATED BUTTON', semanticsLabel: 'ELEVATED BUTTON 2'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
RaisedButton.icon( ElevatedButton.icon(
style: style,
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'),
onPressed: null, onPressed: null,
...@@ -174,7 +165,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -174,7 +165,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
); );
} }
Widget buildFlatButton() { Widget buildTextButton(OutlinedBorder shape) {
final ButtonStyle style = ElevatedButton.styleFrom(shape: shape);
return Align( return Align(
alignment: const Alignment(0.0, -0.2), alignment: const Alignment(0.0, -0.2),
child: Column( child: Column(
...@@ -183,13 +175,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -183,13 +175,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
ButtonBar( ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
FlatButton( TextButton(
child: const Text('FLAT BUTTON', semanticsLabel: 'FLAT BUTTON 1'), style: style,
child: const Text('TEXT BUTTON', semanticsLabel: 'TEXT BUTTON 1'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
const FlatButton( const TextButton(
child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 3',), child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 3',),
onPressed: null, onPressed: null,
), ),
...@@ -198,15 +191,17 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -198,15 +191,17 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
ButtonBar( ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
FlatButton.icon( TextButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 18.0), style: style,
label: const Text('FLAT BUTTON', semanticsLabel: 'FLAT BUTTON 2'), icon: const Icon(Icons.add_circle_outlined, size: 18.0),
label: const Text('TEXT BUTTON', semanticsLabel: 'TEXT BUTTON 2'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
FlatButton.icon( TextButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 18.0), style: style,
icon: const Icon(Icons.add_circle_outlined, size: 18.0),
label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'),
onPressed: null, onPressed: null,
), ),
...@@ -217,7 +212,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -217,7 +212,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
); );
} }
Widget buildOutlineButton() { Widget buildOutlinedButton(OutlinedBorder shape) {
final ButtonStyle style = ElevatedButton.styleFrom(shape: shape);
return Align( return Align(
alignment: const Alignment(0.0, -0.2), alignment: const Alignment(0.0, -0.2),
child: Column( child: Column(
...@@ -226,14 +222,16 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -226,14 +222,16 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
ButtonBar( ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
OutlineButton( OutlinedButton(
child: const Text('OUTLINE BUTTON', semanticsLabel: 'OUTLINE BUTTON 1'), style: style,
child: const Text('OUTLINED BUTTON', semanticsLabel: 'OUTLINED BUTTON 1'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
const OutlineButton( OutlinedButton(
child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 5'), style: style,
child: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 5'),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -241,14 +239,15 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -241,14 +239,15 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
ButtonBar( ButtonBar(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
OutlineButton.icon( OutlinedButton.icon(
style: style,
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('OUTLINE BUTTON', semanticsLabel: 'OUTLINE BUTTON 2'), label: const Text('OUTLINED BUTTON', semanticsLabel: 'OUTLINED BUTTON 2'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
OutlineButton.icon( OutlinedButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 6'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 6'),
onPressed: null, onPressed: null,
......
...@@ -94,7 +94,7 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -94,7 +94,7 @@ class DialogDemoState extends State<DialogDemo> {
body: ListView( body: ListView(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0), padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
children: <Widget>[ children: <Widget>[
RaisedButton( ElevatedButton(
child: const Text('ALERT'), child: const Text('ALERT'),
onPressed: () { onPressed: () {
showDemoDialog<DialogDemoAction>( showDemoDialog<DialogDemoAction>(
...@@ -105,11 +105,11 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -105,11 +105,11 @@ class DialogDemoState extends State<DialogDemo> {
style: dialogTextStyle, style: dialogTextStyle,
), ),
actions: <Widget>[ actions: <Widget>[
FlatButton( TextButton(
child: const Text('CANCEL'), child: const Text('CANCEL'),
onPressed: () { Navigator.pop(context, DialogDemoAction.cancel); }, onPressed: () { Navigator.pop(context, DialogDemoAction.cancel); },
), ),
FlatButton( TextButton(
child: const Text('DISCARD'), child: const Text('DISCARD'),
onPressed: () { Navigator.pop(context, DialogDemoAction.discard); }, onPressed: () { Navigator.pop(context, DialogDemoAction.discard); },
), ),
...@@ -118,7 +118,7 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -118,7 +118,7 @@ class DialogDemoState extends State<DialogDemo> {
); );
}, },
), ),
RaisedButton( ElevatedButton(
child: const Text('ALERT WITH TITLE'), child: const Text('ALERT WITH TITLE'),
onPressed: () { onPressed: () {
showDemoDialog<DialogDemoAction>( showDemoDialog<DialogDemoAction>(
...@@ -130,11 +130,11 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -130,11 +130,11 @@ class DialogDemoState extends State<DialogDemo> {
style: dialogTextStyle, style: dialogTextStyle,
), ),
actions: <Widget>[ actions: <Widget>[
FlatButton( TextButton(
child: const Text('DISAGREE'), child: const Text('DISAGREE'),
onPressed: () { Navigator.pop(context, DialogDemoAction.disagree); }, onPressed: () { Navigator.pop(context, DialogDemoAction.disagree); },
), ),
FlatButton( TextButton(
child: const Text('AGREE'), child: const Text('AGREE'),
onPressed: () { Navigator.pop(context, DialogDemoAction.agree); }, onPressed: () { Navigator.pop(context, DialogDemoAction.agree); },
), ),
...@@ -143,7 +143,7 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -143,7 +143,7 @@ class DialogDemoState extends State<DialogDemo> {
); );
}, },
), ),
RaisedButton( ElevatedButton(
child: const Text('SIMPLE'), child: const Text('SIMPLE'),
onPressed: () { onPressed: () {
showDemoDialog<String>( showDemoDialog<String>(
...@@ -173,7 +173,7 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -173,7 +173,7 @@ class DialogDemoState extends State<DialogDemo> {
); );
}, },
), ),
RaisedButton( ElevatedButton(
child: const Text('CONFIRMATION'), child: const Text('CONFIRMATION'),
onPressed: () { onPressed: () {
showTimePicker( showTimePicker(
...@@ -190,7 +190,7 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -190,7 +190,7 @@ class DialogDemoState extends State<DialogDemo> {
}); });
}, },
), ),
RaisedButton( ElevatedButton(
child: const Text('FULLSCREEN'), child: const Text('FULLSCREEN'),
onPressed: () { onPressed: () {
Navigator.push(context, MaterialPageRoute<DismissDialogAction>( Navigator.push(context, MaterialPageRoute<DismissDialogAction>(
......
...@@ -119,7 +119,7 @@ class CollapsibleBody extends StatelessWidget { ...@@ -119,7 +119,7 @@ class CollapsibleBody extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Container( Container(
margin: const EdgeInsets.only(right: 8.0), margin: const EdgeInsets.only(right: 8.0),
child: FlatButton( child: TextButton(
onPressed: onCancel, onPressed: onCancel,
child: const Text('CANCEL', style: TextStyle( child: const Text('CANCEL', style: TextStyle(
color: Colors.black54, color: Colors.black54,
...@@ -130,9 +130,8 @@ class CollapsibleBody extends StatelessWidget { ...@@ -130,9 +130,8 @@ class CollapsibleBody extends StatelessWidget {
), ),
Container( Container(
margin: const EdgeInsets.only(right: 8.0), margin: const EdgeInsets.only(right: 8.0),
child: FlatButton( child: TextButton(
onPressed: onSave, onPressed: onSave,
textTheme: ButtonTextTheme.accent,
child: const Text('SAVE'), child: const Text('SAVE'),
), ),
), ),
......
...@@ -17,7 +17,7 @@ class ModalBottomSheetDemo extends StatelessWidget { ...@@ -17,7 +17,7 @@ class ModalBottomSheetDemo extends StatelessWidget {
actions: <Widget>[MaterialDemoDocumentationButton(routeName)], actions: <Widget>[MaterialDemoDocumentationButton(routeName)],
), ),
body: Center( body: Center(
child: RaisedButton( child: ElevatedButton(
child: const Text('SHOW BOTTOM SHEET'), child: const Text('SHOW BOTTOM SHEET'),
onPressed: () { onPressed: () {
showModalBottomSheet<void>(context: context, builder: (BuildContext context) { showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
......
...@@ -62,7 +62,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { ...@@ -62,7 +62,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
return AlertDialog( return AlertDialog(
content: const Text('You tapped the floating action button.'), content: const Text('You tapped the floating action button.'),
actions: <Widget>[ actions: <Widget>[
FlatButton( TextButton(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
...@@ -93,7 +93,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { ...@@ -93,7 +93,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
), ),
), ),
body: Center( body: Center(
child: RaisedButton( child: ElevatedButton(
onPressed: _showBottomSheetCallback, onPressed: _showBottomSheetCallback,
child: const Text('SHOW BOTTOM SHEET'), child: const Text('SHOW BOTTOM SHEET'),
), ),
......
...@@ -40,7 +40,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> { ...@@ -40,7 +40,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
const Text(_text1), const Text(_text1),
const Text(_text2), const Text(_text2),
Center( Center(
child: RaisedButton( child: ElevatedButton(
child: const Text('SHOW A SNACKBAR'), child: const Text('SHOW A SNACKBAR'),
onPressed: () { onPressed: () {
final int thisSnackBarIndex = _snackBarIndex++; final int thisSnackBarIndex = _snackBarIndex++;
......
...@@ -150,11 +150,11 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -150,11 +150,11 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
title: const Text('This form has errors'), title: const Text('This form has errors'),
content: const Text('Really leave this form?'), content: const Text('Really leave this form?'),
actions: <Widget> [ actions: <Widget> [
FlatButton( TextButton(
child: const Text('YES'), child: const Text('YES'),
onPressed: () { Navigator.of(context).pop(true); }, onPressed: () { Navigator.of(context).pop(true); },
), ),
FlatButton( TextButton(
child: const Text('NO'), child: const Text('NO'),
onPressed: () { Navigator.of(context).pop(false); }, onPressed: () { Navigator.of(context).pop(false); },
), ),
...@@ -279,7 +279,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -279,7 +279,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
), ),
const SizedBox(height: 24.0), const SizedBox(height: 24.0),
Center( Center(
child: RaisedButton( child: ElevatedButton(
child: const Text('SUBMIT'), child: const Text('SUBMIT'),
onPressed: _handleSubmitted, onPressed: _handleSubmitted,
), ),
......
...@@ -84,10 +84,11 @@ class _LoginPageState extends State<LoginPage> { ...@@ -84,10 +84,11 @@ class _LoginPageState extends State<LoginPage> {
children: <Widget>[ children: <Widget>[
ButtonBar( ButtonBar(
children: <Widget>[ children: <Widget>[
FlatButton( TextButton(
child: const Text('CANCEL'), style: TextButton.styleFrom(
shape: const BeveledRectangleBorder( shape: const BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)), borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
), ),
onPressed: () { onPressed: () {
// The login screen is immediately displayed on top of // The login screen is immediately displayed on top of
...@@ -96,16 +97,19 @@ class _LoginPageState extends State<LoginPage> { ...@@ -96,16 +97,19 @@ class _LoginPageState extends State<LoginPage> {
// of Shrine completely. // of Shrine completely.
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
}, },
child: const Text('CANCEL'),
), ),
RaisedButton( ElevatedButton(
child: const Text('NEXT'), style: ElevatedButton.styleFrom(
elevation: 8.0, elevation: 8.0,
shape: const BeveledRectangleBorder( shape: const BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)), borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
), ),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
child: const Text('NEXT'),
), ),
], ],
), ),
......
...@@ -75,12 +75,13 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> { ...@@ -75,12 +75,13 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
bottom: 16.0, bottom: 16.0,
left: 16.0, left: 16.0,
right: 16.0, right: 16.0,
child: RaisedButton( child: ElevatedButton(
shape: const BeveledRectangleBorder( style: ElevatedButton.styleFrom(
borderRadius: BorderRadius.all(Radius.circular(7.0)), primary: kShrinePink100,
shape: const BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
), ),
color: kShrinePink100,
splashColor: kShrineBrown600,
child: const Padding( child: const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0), padding: EdgeInsets.symmetric(vertical: 12.0),
child: Text('CLEAR CART'), child: Text('CLEAR CART'),
......
...@@ -13,9 +13,9 @@ class ButtonsDemo { ...@@ -13,9 +13,9 @@ class ButtonsDemo {
void buttons() { void buttons() {
// START buttons_raised // START buttons_elevated
// Create a raised button. // Create an elevated button.
RaisedButton( ElevatedButton(
child: const Text('BUTTON TITLE'), child: const Text('BUTTON TITLE'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
...@@ -25,14 +25,14 @@ RaisedButton( ...@@ -25,14 +25,14 @@ RaisedButton(
// Create a disabled button. // Create a disabled button.
// Buttons are disabled when onPressed isn't // Buttons are disabled when onPressed isn't
// specified or is null. // specified or is null.
const RaisedButton( const ElevatedButton(
child: Text('BUTTON TITLE'), child: Text('BUTTON TITLE'),
onPressed: null, onPressed: null,
); );
// Create a button with an icon and a // Create a button with an icon and a
// title. // title.
RaisedButton.icon( ElevatedButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('BUTTON TITLE'), label: const Text('BUTTON TITLE'),
onPressed: () { onPressed: () {
...@@ -41,9 +41,9 @@ RaisedButton.icon( ...@@ -41,9 +41,9 @@ RaisedButton.icon(
); );
// END // END
// START buttons_outline // START buttons_outlined
// Create an outline button. // Create an outlined button.
OutlineButton( OutlinedButton(
child: const Text('BUTTON TITLE'), child: const Text('BUTTON TITLE'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
...@@ -53,14 +53,14 @@ OutlineButton( ...@@ -53,14 +53,14 @@ OutlineButton(
// Create a disabled button. // Create a disabled button.
// Buttons are disabled when onPressed isn't // Buttons are disabled when onPressed isn't
// specified or is null. // specified or is null.
const OutlineButton( const OutlinedButton(
child: Text('BUTTON TITLE'), child: Text('BUTTON TITLE'),
onPressed: null, onPressed: null,
); );
// Create a button with an icon and a // Create a button with an icon and a
// title. // title.
OutlineButton.icon( OutlinedButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('BUTTON TITLE'), label: const Text('BUTTON TITLE'),
onPressed: () { onPressed: () {
...@@ -69,9 +69,9 @@ OutlineButton.icon( ...@@ -69,9 +69,9 @@ OutlineButton.icon(
); );
// END // END
// START buttons_flat // START buttons_text
// Create a flat button. // Create a text button.
FlatButton( TextButton(
child: const Text('BUTTON TITLE'), child: const Text('BUTTON TITLE'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
...@@ -81,7 +81,7 @@ FlatButton( ...@@ -81,7 +81,7 @@ FlatButton(
// Create a disabled button. // Create a disabled button.
// Buttons are disabled when onPressed isn't // Buttons are disabled when onPressed isn't
// specified or is null. // specified or is null.
const FlatButton( const TextButton(
child: Text('BUTTON TITLE'), child: Text('BUTTON TITLE'),
onPressed: null, onPressed: null,
); );
......
...@@ -158,7 +158,7 @@ class _ActionItem extends StatelessWidget { ...@@ -158,7 +158,7 @@ class _ActionItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _OptionsItem( return _OptionsItem(
child: _FlatButton( child: _TextButton(
onPressed: onTap, onPressed: onTap,
child: Text(text), child: Text(text),
), ),
...@@ -166,21 +166,23 @@ class _ActionItem extends StatelessWidget { ...@@ -166,21 +166,23 @@ class _ActionItem extends StatelessWidget {
} }
} }
class _FlatButton extends StatelessWidget { class _TextButton extends StatelessWidget {
const _FlatButton({ Key key, this.onPressed, this.child }) : super(key: key); const _TextButton({ Key key, this.onPressed, this.child }) : super(key: key);
final VoidCallback onPressed; final VoidCallback onPressed;
final Widget child; final Widget child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FlatButton( final ThemeData theme = Theme.of(context);
padding: EdgeInsets.zero, return TextButton(
onPressed: onPressed, style: TextButton.styleFrom(
child: DefaultTextStyle( primary: theme.colorScheme.onPrimary,
style: Theme.of(context).primaryTextTheme.subtitle1, textStyle: theme.textTheme.subtitle1,
child: child, padding: EdgeInsets.zero,
), ),
onPressed: onPressed,
child: child,
); );
} }
} }
......
...@@ -21,7 +21,7 @@ ThemeData _buildDarkTheme() { ...@@ -21,7 +21,7 @@ ThemeData _buildDarkTheme() {
final ColorScheme colorScheme = const ColorScheme.dark().copyWith( final ColorScheme colorScheme = const ColorScheme.dark().copyWith(
primary: primaryColor, primary: primaryColor,
secondary: secondaryColor, secondary: secondaryColor,
onPrimary: secondaryColor, onPrimary: Colors.white,
); );
final ThemeData base = ThemeData( final ThemeData base = ThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
...@@ -30,7 +30,6 @@ ThemeData _buildDarkTheme() { ...@@ -30,7 +30,6 @@ ThemeData _buildDarkTheme() {
primaryColor: primaryColor, primaryColor: primaryColor,
primaryColorDark: const Color(0xFF0050a0), primaryColorDark: const Color(0xFF0050a0),
primaryColorLight: secondaryColor, primaryColorLight: secondaryColor,
buttonColor: primaryColor,
indicatorColor: Colors.white, indicatorColor: Colors.white,
toggleableActiveColor: const Color(0xFF6997DF), toggleableActiveColor: const Color(0xFF6997DF),
accentColor: secondaryColor, accentColor: secondaryColor,
...@@ -38,10 +37,6 @@ ThemeData _buildDarkTheme() { ...@@ -38,10 +37,6 @@ ThemeData _buildDarkTheme() {
scaffoldBackgroundColor: const Color(0xFF202124), scaffoldBackgroundColor: const Color(0xFF202124),
backgroundColor: const Color(0xFF202124), backgroundColor: const Color(0xFF202124),
errorColor: const Color(0xFFB00020), errorColor: const Color(0xFFB00020),
buttonTheme: ButtonThemeData(
colorScheme: colorScheme,
textTheme: ButtonTextTheme.primary,
),
); );
return base.copyWith( return base.copyWith(
textTheme: _buildTextTheme(base.textTheme), textTheme: _buildTextTheme(base.textTheme),
...@@ -62,7 +57,6 @@ ThemeData _buildLightTheme() { ...@@ -62,7 +57,6 @@ ThemeData _buildLightTheme() {
accentColorBrightness: Brightness.dark, accentColorBrightness: Brightness.dark,
colorScheme: colorScheme, colorScheme: colorScheme,
primaryColor: primaryColor, primaryColor: primaryColor,
buttonColor: primaryColor,
indicatorColor: Colors.white, indicatorColor: Colors.white,
toggleableActiveColor: const Color(0xFF1E88E5), toggleableActiveColor: const Color(0xFF1E88E5),
splashColor: Colors.white24, splashColor: Colors.white24,
...@@ -72,10 +66,6 @@ ThemeData _buildLightTheme() { ...@@ -72,10 +66,6 @@ ThemeData _buildLightTheme() {
scaffoldBackgroundColor: Colors.white, scaffoldBackgroundColor: Colors.white,
backgroundColor: Colors.white, backgroundColor: Colors.white,
errorColor: const Color(0xFFB00020), errorColor: const Color(0xFFB00020),
buttonTheme: ButtonThemeData(
colorScheme: colorScheme,
textTheme: ButtonTextTheme.primary,
),
); );
return base.copyWith( return base.copyWith(
textTheme: _buildTextTheme(base.textTheme), textTheme: _buildTextTheme(base.textTheme),
......
...@@ -52,13 +52,13 @@ class UpdaterState extends State<Updater> { ...@@ -52,13 +52,13 @@ class UpdaterState extends State<Updater> {
title: const Text('Update Flutter Gallery?'), title: const Text('Update Flutter Gallery?'),
content: Text('A newer version is available.', style: dialogTextStyle), content: Text('A newer version is available.', style: dialogTextStyle),
actions: <Widget>[ actions: <Widget>[
FlatButton( TextButton(
child: const Text('NO THANKS'), child: const Text('NO THANKS'),
onPressed: () { onPressed: () {
Navigator.pop(context, false); Navigator.pop(context, false);
}, },
), ),
FlatButton( TextButton(
child: const Text('UPDATE'), child: const Text('UPDATE'),
onPressed: () { onPressed: () {
Navigator.pop(context, true); Navigator.pop(context, true);
......
...@@ -478,14 +478,12 @@ void main() { ...@@ -478,14 +478,12 @@ void main() {
group('All material demos meet text contrast guidelines', () { group('All material demos meet text contrast guidelines', () {
final List<ThemeData> themes = <ThemeData>[ final List<ThemeData> themes = <ThemeData>[
kLightGalleryTheme, kLightGalleryTheme,
ThemeData.light(), kDarkGalleryTheme,
ThemeData.dark(),
]; ];
const List<String> themeNames = <String>[ const List<String> themeNames = <String>[
'kLightGalleryTheme', 'kLightGalleryTheme',
'ThemeData.light()', 'kDarkGalleryTheme',
'ThemeData.dark()',
]; ];
for (int themeIndex = 0; themeIndex < themes.length; themeIndex += 1) { for (int themeIndex = 0; themeIndex < themes.length; themeIndex += 1) {
......
...@@ -10,7 +10,7 @@ void main() { ...@@ -10,7 +10,7 @@ void main() {
testWidgets('validates name field correctly', (WidgetTester tester) async { testWidgets('validates name field correctly', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: TextFormFieldDemo())); await tester.pumpWidget(const MaterialApp(home: TextFormFieldDemo()));
final Finder submitButton = find.widgetWithText(RaisedButton, 'SUBMIT'); final Finder submitButton = find.widgetWithText(ElevatedButton, 'SUBMIT');
expect(submitButton, findsOneWidget); expect(submitButton, findsOneWidget);
final Finder nameField = find.widgetWithText(TextFormField, 'Name *'); final Finder nameField = find.widgetWithText(TextFormField, 'Name *');
......
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