Migrate to the New Material Buttons (#668)

pull/679/head
Brett Morgan 5 years ago committed by GitHub
parent 6502209a78
commit 622e8d55d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -138,7 +138,7 @@ class Contents extends StatelessWidget {
SizedBox(height: 16), SizedBox(height: 16),
Consumer<CounterModel>( Consumer<CounterModel>(
builder: (context, model, child) { builder: (context, model, child) {
return RaisedButton( return ElevatedButton(
onPressed: () => model.increment(), onPressed: () => model.increment(),
child: Text('Tap me!'), child: Text('Tap me!'),
); );
@ -146,7 +146,7 @@ class Contents extends StatelessWidget {
), ),
if (showExit) ...[ if (showExit) ...[
SizedBox(height: 16), SizedBox(height: 16),
RaisedButton( ElevatedButton(
onPressed: () => SystemNavigator.pop(animated: true), onPressed: () => SystemNavigator.pop(animated: true),
child: Text('Exit this screen'), child: Text('Exit this screen'),
), ),

@ -140,13 +140,13 @@ class Contents extends StatelessWidget {
SizedBox(height: 16), SizedBox(height: 16),
Consumer<CounterModel>( Consumer<CounterModel>(
builder: (context, model, child) { builder: (context, model, child) {
return RaisedButton( return ElevatedButton(
onPressed: () => model.increment(), onPressed: () => model.increment(),
child: Text('Tap me!'), child: Text('Tap me!'),
); );
}, },
), ),
RaisedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
// Use the url_launcher plugin to open the Flutter docs in // Use the url_launcher plugin to open the Flutter docs in
// a browser. // a browser.
@ -159,7 +159,7 @@ class Contents extends StatelessWidget {
), ),
if (showExit) ...[ if (showExit) ...[
SizedBox(height: 16), SizedBox(height: 16),
RaisedButton( ElevatedButton(
onPressed: () => SystemNavigator.pop(), onPressed: () => SystemNavigator.pop(),
child: Text('Exit this screen'), child: Text('Exit this screen'),
), ),

@ -69,7 +69,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
), ),
), ),
), ),
RaisedButton( ElevatedButton(
child: Text( child: Text(
'change', 'change',
), ),

@ -14,7 +14,7 @@ class PageRouteBuilderDemo extends StatelessWidget {
title: Text('Page 1'), title: Text('Page 1'),
), ),
body: Center( body: Center(
child: RaisedButton( child: ElevatedButton(
child: Text('Go!'), child: Text('Go!'),
onPressed: () { onPressed: () {
Navigator.of(context).push<void>(_createRoute()); Navigator.of(context).push<void>(_createRoute());

@ -68,7 +68,7 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
textScaleFactor: 1 + controller.value, textScaleFactor: 1 + controller.value,
), ),
), ),
RaisedButton( ElevatedButton(
child: Text('animate'), child: Text('animate'),
onPressed: () { onPressed: () {
if (controller.status == AnimationStatus.completed) { if (controller.status == AnimationStatus.completed) {

@ -51,7 +51,7 @@ class _TweenDemoState extends State<TweenDemo>
child: Text('\$${animation.value.toStringAsFixed(2)}', child: Text('\$${animation.value.toStringAsFixed(2)}',
style: TextStyle(fontSize: 24)), style: TextStyle(fontSize: 24)),
), ),
RaisedButton( ElevatedButton(
child: Text( child: Text(
controller.status == AnimationStatus.completed controller.status == AnimationStatus.completed
? 'Buy a Mansion' ? 'Buy a Mansion'

@ -61,7 +61,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
size: 300, size: 300,
), ),
), ),
RaisedButton( ElevatedButton(
child: Text('animate'), child: Text('animate'),
onPressed: () => setState(() { onPressed: () => setState(() {
_controller.animateTo(1.0).then<TickerFuture>( _controller.animateTo(1.0).then<TickerFuture>(

@ -59,7 +59,7 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
), ),
), ),
), ),
RaisedButton( ElevatedButton(
child: const Text('Refill'), child: const Text('Refill'),
onPressed: () { onPressed: () {
setState(() { setState(() {

@ -146,7 +146,7 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
), ),
), ),
SizedBox(height: 25.0), SizedBox(height: 25.0),
RaisedButton( ElevatedButton(
onPressed: () { onPressed: () {
controller.forward(); controller.forward();
}, },

@ -56,7 +56,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Tap the Refill button. // Tap the Refill button.
await tester.tap(find.byType(RaisedButton)); await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Check if the entire stack is refilled. // Check if the entire stack is refilled.

@ -50,13 +50,13 @@ class _PhotoSearchDialogState extends State<PhotoSearchDialog> {
}, },
), ),
actions: <Widget>[ actions: <Widget>[
FlatButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: Text('Cancel'.toUpperCase()), child: Text('Cancel'.toUpperCase()),
), ),
FlatButton( TextButton(
onPressed: _searchEnabled onPressed: _searchEnabled
? () { ? () {
widget.callback(_controller.text); widget.callback(_controller.text);

@ -90,7 +90,7 @@ class PhotoSearchModelTester extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
home: FlatButton( home: TextButton(
key: fabKey, key: fabKey,
onPressed: () async { onPressed: () async {
await Provider.of<PhotoSearchModel>( await Provider.of<PhotoSearchModel>(

@ -47,7 +47,7 @@ class _HomePageState extends State<HomePage> {
style: Theme.of(context).textTheme.headline5, style: Theme.of(context).textTheme.headline5,
), ),
SizedBox(height: 16), SizedBox(height: 16),
RaisedButton( ElevatedButton(
child: Text('Get Battery Level'), child: Text('Get Battery Level'),
onPressed: () async { onPressed: () async {
try { try {

@ -22,7 +22,7 @@ void main() {
await tester.pumpWidget(MyApp()); await tester.pumpWidget(MyApp());
// Tap button to retrieve current battery level from platform. // Tap button to retrieve current battery level from platform.
await tester.tap(find.byType(RaisedButton)); await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Battery Level: $batteryLevel'), findsOneWidget); expect(find.text('Battery Level: $batteryLevel'), findsOneWidget);

@ -30,8 +30,8 @@ class _HomePageState extends State<HomePage> {
actions: [ actions: [
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: FlatButton( child: TextButton(
textColor: Colors.white, style: TextButton.styleFrom(primary: Colors.white),
onPressed: () => _handleSignOut(), onPressed: () => _handleSignOut(),
child: Text('Sign Out'), child: Text('Sign Out'),
), ),
@ -90,13 +90,13 @@ class _HomePageState extends State<HomePage> {
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: Text('Are you sure you want to sign out?'), title: Text('Are you sure you want to sign out?'),
actions: [ actions: [
FlatButton( TextButton(
child: Text('No'), child: Text('No'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(false); Navigator.of(context).pop(false);
}, },
), ),
FlatButton( TextButton(
child: Text('Yes'), child: Text('Yes'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(true); Navigator.of(context).pop(true);

@ -86,7 +86,7 @@ class _SignInButtonState extends State<SignInButton> {
_showError(); _showError();
} }
return RaisedButton( return ElevatedButton(
child: Text('Sign In with Google'), child: Text('Sign In with Google'),
onPressed: () => _signIn(), onPressed: () => _signIn(),
); );

@ -76,7 +76,7 @@ class _EditCategoryFormState extends State<EditCategoryForm> {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: RaisedButton( child: ElevatedButton(
child: Text('Cancel'), child: Text('Cancel'),
onPressed: () { onPressed: () {
widget.onDone(false); widget.onDone(false);
@ -85,7 +85,7 @@ class _EditCategoryFormState extends State<EditCategoryForm> {
), ),
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: RaisedButton( child: ElevatedButton(
child: Text('OK'), child: Text('OK'),
onPressed: () { onPressed: () {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {

@ -103,7 +103,7 @@ class _EditEntryFormState extends State<EditEntryForm> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(intl.DateFormat('MM/dd/yyyy').format(widget.entry.time)), Text(intl.DateFormat('MM/dd/yyyy').format(widget.entry.time)),
RaisedButton( ElevatedButton(
child: Text('Edit'), child: Text('Edit'),
onPressed: () async { onPressed: () async {
var result = await showDatePicker( var result = await showDatePicker(
@ -127,7 +127,7 @@ class _EditEntryFormState extends State<EditEntryForm> {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: RaisedButton( child: ElevatedButton(
child: Text('Cancel'), child: Text('Cancel'),
onPressed: () { onPressed: () {
widget.onDone(false); widget.onDone(false);
@ -136,7 +136,7 @@ class _EditEntryFormState extends State<EditEntryForm> {
), ),
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: RaisedButton( child: ElevatedButton(
child: Text('OK'), child: Text('OK'),
onPressed: () { onPressed: () {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {

@ -190,7 +190,7 @@ class _FormDatePickerState extends State<_FormDatePicker> {
), ),
], ],
), ),
FlatButton( TextButton(
child: Text('Edit'), child: Text('Edit'),
onPressed: () async { onPressed: () async {
var newDate = await showDatePicker( var newDate = await showDatePicker(

@ -73,7 +73,7 @@ class _SignInHttpDemoState extends State<SignInHttpDemo> {
formData.password = value; formData.password = value;
}, },
), ),
FlatButton( TextButton(
child: Text('Sign in'), child: Text('Sign in'),
onPressed: () async { onPressed: () async {
// Use a JSON encoded string to send // Use a JSON encoded string to send
@ -113,7 +113,7 @@ class _SignInHttpDemoState extends State<SignInHttpDemo> {
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: Text(message), title: Text(message),
actions: [ actions: [
FlatButton( TextButton(
child: Text('OK'), child: Text('OK'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),

@ -24,8 +24,8 @@ class _FormValidationDemoState extends State<FormValidationDemo> {
actions: [ actions: [
Padding( Padding(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: FlatButton( child: TextButton(
textColor: Colors.white, style: TextButton.styleFrom(primary: Colors.white),
child: Text('Submit'), child: Text('Submit'),
onPressed: () { onPressed: () {
// Validate the form by getting the FormState from the GlobalKey // Validate the form by getting the FormState from the GlobalKey
@ -41,7 +41,7 @@ class _FormValidationDemoState extends State<FormValidationDemo> {
title: Text('Your story'), title: Text('Your story'),
content: Text('The $adjective developer saw a $noun'), content: Text('The $adjective developer saw a $noun'),
actions: [ actions: [
FlatButton( TextButton(
child: Text('Done'), child: Text('Done'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();

@ -54,25 +54,28 @@ class DataTransferPage extends StatelessWidget {
), ),
Column( Column(
children: [ children: [
RaisedButton( ElevatedButton(
child: const Text('Transfer Data to 2nd Isolate'), child: const Text('Transfer Data to 2nd Isolate'),
color: (controller.runningTest == 1) style: ElevatedButton.styleFrom(
primary: (controller.runningTest == 1)
? Colors.blueAccent ? Colors.blueAccent
: Colors.grey[300], : Colors.grey[300]),
onPressed: () => controller.generateRandomNumbers(false), onPressed: () => controller.generateRandomNumbers(false),
), ),
RaisedButton( ElevatedButton(
child: const Text('Transfer Data with TransferableTypedData'), child: const Text('Transfer Data with TransferableTypedData'),
color: (controller.runningTest == 2) style: ElevatedButton.styleFrom(
primary: (controller.runningTest == 2)
? Colors.blueAccent ? Colors.blueAccent
: Colors.grey[300], : Colors.grey[300]),
onPressed: () => controller.generateRandomNumbers(true), onPressed: () => controller.generateRandomNumbers(true),
), ),
RaisedButton( ElevatedButton(
child: const Text('Generate on 2nd Isolate'), child: const Text('Generate on 2nd Isolate'),
color: (controller.runningTest == 3) style: ElevatedButton.styleFrom(
primary: (controller.runningTest == 3)
? Colors.blueAccent ? Colors.blueAccent
: Colors.grey[300], : Colors.grey[300]),
onPressed: controller.generateOnSecondaryIsolate, onPressed: controller.generateOnSecondaryIsolate,
), ),
], ],

@ -53,14 +53,14 @@ class InfiniteProcessPage extends StatelessWidget {
ButtonBar( ButtonBar(
alignment: MainAxisAlignment.center, alignment: MainAxisAlignment.center,
children: [ children: [
RaisedButton( ElevatedButton(
child: const Text('Start'), child: const Text('Start'),
elevation: 8.0, style: ElevatedButton.styleFrom(elevation: 8.0),
onPressed: () => controller.start(), onPressed: () => controller.start(),
), ),
RaisedButton( ElevatedButton(
child: const Text('Terminate'), child: const Text('Terminate'),
elevation: 8.0, style: ElevatedButton.styleFrom(elevation: 8.0),
onPressed: () => controller.terminate(), onPressed: () => controller.terminate(),
), ),
], ],

@ -52,9 +52,9 @@ class _PerformancePageState extends State<PerformancePage> {
FutureBuilder( FutureBuilder(
future: computeFuture, future: computeFuture,
builder: (context, snapshot) { builder: (context, snapshot) {
return RaisedButton( return ElevatedButton(
child: const Text('Compute on Main'), child: const Text('Compute on Main'),
elevation: 8.0, style: ElevatedButton.styleFrom(elevation: 8.0),
onPressed: onPressed:
snapshot.connectionState == ConnectionState.done snapshot.connectionState == ConnectionState.done
? () => handleComputeOnMain(context) ? () => handleComputeOnMain(context)
@ -65,9 +65,9 @@ class _PerformancePageState extends State<PerformancePage> {
FutureBuilder( FutureBuilder(
future: computeFuture, future: computeFuture,
builder: (context, snapshot) { builder: (context, snapshot) {
return RaisedButton( return ElevatedButton(
child: const Text('Compute on Secondary'), child: const Text('Compute on Secondary'),
elevation: 8.0, style: ElevatedButton.styleFrom(elevation: 8.0),
onPressed: onPressed:
snapshot.connectionState == ConnectionState.done snapshot.connectionState == ConnectionState.done
? () => handleComputeOnSecondary(context) ? () => handleComputeOnSecondary(context)

@ -27,7 +27,7 @@ class HomeScreen extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
body: Center( body: Center(
child: FlatButton( child: TextButton(
child: Text('View Details'), child: Text('View Details'),
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
@ -49,7 +49,7 @@ class DetailScreen extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
body: Center( body: Center(
child: FlatButton( child: TextButton(
child: Text('Pop!'), child: Text('Pop!'),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);

@ -30,7 +30,7 @@ class HomeScreen extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
body: Center( body: Center(
child: FlatButton( child: TextButton(
child: Text('View Details'), child: Text('View Details'),
onPressed: () { onPressed: () {
Navigator.pushNamed( Navigator.pushNamed(
@ -50,7 +50,7 @@ class DetailScreen extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
body: Center( body: Center(
child: FlatButton( child: TextButton(
child: Text('Pop!'), child: Text('Pop!'),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);

@ -42,7 +42,7 @@ class HomeScreen extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
body: Center( body: Center(
child: FlatButton( child: TextButton(
child: Text('View Details'), child: Text('View Details'),
onPressed: () { onPressed: () {
Navigator.pushNamed( Navigator.pushNamed(
@ -72,7 +72,7 @@ class DetailScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text('Viewing details for item $id'), Text('Viewing details for item $id'),
FlatButton( TextButton(
child: Text('Pop!'), child: Text('Pop!'),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);

@ -377,7 +377,7 @@ class BookDetailsScreen extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
FlatButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },

@ -102,7 +102,7 @@ class _CategoryButton extends StatelessWidget {
), ),
child: ButtonTheme( child: ButtonTheme(
height: 50.0, height: 50.0,
child: FlatButton( child: TextButton(
child: Text( child: Text(
_buttonText, _buttonText,
style: TextStyle( style: TextStyle(

@ -479,16 +479,16 @@ class _AddPlaceButtonBar extends StatelessWidget {
child: ButtonBar( child: ButtonBar(
alignment: MainAxisAlignment.center, alignment: MainAxisAlignment.center,
children: [ children: [
RaisedButton( ElevatedButton(
color: Colors.blue, style: ElevatedButton.styleFrom(primary: Colors.blue),
child: const Text( child: const Text(
'Save', 'Save',
style: TextStyle(color: Colors.white, fontSize: 16.0), style: TextStyle(color: Colors.white, fontSize: 16.0),
), ),
onPressed: onSavePressed, onPressed: onSavePressed,
), ),
RaisedButton( ElevatedButton(
color: Colors.red, style: ElevatedButton.styleFrom(primary: Colors.red),
child: const Text( child: const Text(
'Cancel', 'Cancel',
style: TextStyle(color: Colors.white, fontSize: 16.0), style: TextStyle(color: Colors.white, fontSize: 16.0),
@ -527,30 +527,33 @@ class _CategoryButtonBar extends StatelessWidget {
child: ButtonBar( child: ButtonBar(
alignment: MainAxisAlignment.center, alignment: MainAxisAlignment.center,
children: [ children: [
RaisedButton( ElevatedButton(
color: selectedPlaceCategory == PlaceCategory.favorite style: ElevatedButton.styleFrom(
primary: selectedPlaceCategory == PlaceCategory.favorite
? Colors.green[700] ? Colors.green[700]
: Colors.lightGreen, : Colors.lightGreen),
child: const Text( child: const Text(
'Favorites', 'Favorites',
style: TextStyle(color: Colors.white, fontSize: 14.0), style: TextStyle(color: Colors.white, fontSize: 14.0),
), ),
onPressed: () => onChanged(PlaceCategory.favorite), onPressed: () => onChanged(PlaceCategory.favorite),
), ),
RaisedButton( ElevatedButton(
color: selectedPlaceCategory == PlaceCategory.visited style: ElevatedButton.styleFrom(
primary: selectedPlaceCategory == PlaceCategory.visited
? Colors.green[700] ? Colors.green[700]
: Colors.lightGreen, : Colors.lightGreen),
child: const Text( child: const Text(
'Visited', 'Visited',
style: TextStyle(color: Colors.white, fontSize: 14.0), style: TextStyle(color: Colors.white, fontSize: 14.0),
), ),
onPressed: () => onChanged(PlaceCategory.visited), onPressed: () => onChanged(PlaceCategory.visited),
), ),
RaisedButton( ElevatedButton(
color: selectedPlaceCategory == PlaceCategory.wantToGo style: ElevatedButton.styleFrom(
primary: selectedPlaceCategory == PlaceCategory.wantToGo
? Colors.green[700] ? Colors.green[700]
: Colors.lightGreen, : Colors.lightGreen),
child: const Text( child: const Text(
'Want To Go', 'Want To Go',
style: TextStyle(color: Colors.white, fontSize: 14.0), style: TextStyle(color: Colors.white, fontSize: 14.0),

@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:platform_channels/src/counter_method_channel.dart'; import 'package:platform_channels/src/counter_method_channel.dart';
/// The widget demonstrates how to use [MethodChannel] to invoke platform methods. /// The widget demonstrates how to use [MethodChannel] to invoke platform methods.
/// It has two [RaisedButton]s to increment and decrement the value of /// It has two [ElevatedButton]s to increment and decrement the value of
/// [count], and a [Text] widget to display its value. /// [count], and a [Text] widget to display its value.
class MethodChannelDemo extends StatefulWidget { class MethodChannelDemo extends StatefulWidget {
@override @override
@ -37,9 +37,9 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
// Whenever users press the RaisedButton, it invokes // Whenever users press the ElevatedButton, it invokes
// Counter.increment method to increment the value of count. // Counter.increment method to increment the value of count.
RaisedButton.icon( ElevatedButton.icon(
onPressed: () async { onPressed: () async {
try { try {
final value = final value =
@ -56,9 +56,9 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
label: Text('Increment'), label: Text('Increment'),
), ),
// Whenever users press the RaisedButton, it invokes // Whenever users press the ElevatedButton, it invokes
// Counter.decrement method to decrement the value of count. // Counter.decrement method to decrement the value of count.
RaisedButton.icon( ElevatedButton.icon(
onPressed: () async { onPressed: () async {
try { try {
final value = final value =

@ -58,7 +58,7 @@ class _PlatformImageDemoState extends State<PlatformImageDemo> {
SizedBox( SizedBox(
height: 16, height: 16,
), ),
RaisedButton( ElevatedButton(
onPressed: imageData != null onPressed: imageData != null
? null ? null
: () { : () {

@ -33,13 +33,13 @@ void main() {
// Initially the value of count should be 0. // Initially the value of count should be 0.
expect(find.text('Value of count is 0'), findsOneWidget); expect(find.text('Value of count is 0'), findsOneWidget);
// Tap the RaisedButton with Icons.add to increment the value of count. // Tap the ElevatedButton with Icons.add to increment the value of count.
await tester.tap(find.byIcon(Icons.add)); await tester.tap(find.byIcon(Icons.add));
await tester.pump(); await tester.pump();
expect(find.text('Value of count is 1'), findsOneWidget); expect(find.text('Value of count is 1'), findsOneWidget);
// Tap the RaisedButton with Icons.remove to decrement the value of count. // Tap the ElevatedButton with Icons.remove to decrement the value of count.
await tester.tap(find.byIcon(Icons.remove)); await tester.tap(find.byIcon(Icons.remove));
await tester.pump(); await tester.pump();

@ -27,8 +27,8 @@ void main() {
expect(find.byType(Placeholder), findsOneWidget); expect(find.byType(Placeholder), findsOneWidget);
expect(find.byType(Image), findsNothing); expect(find.byType(Image), findsNothing);
// Tap on RaisedButton to get Image. // Tap on ElevatedButton to get Image.
await tester.tap(find.byType(RaisedButton)); await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(Placeholder), findsNothing); expect(find.byType(Placeholder), findsNothing);

@ -177,7 +177,7 @@ class LogOutButton extends StatelessWidget {
// =========================================================================== // ===========================================================================
Widget _buildAndroid(BuildContext context) { Widget _buildAndroid(BuildContext context) {
return RaisedButton( return ElevatedButton(
child: Text('LOG OUT', style: TextStyle(color: Colors.red)), child: Text('LOG OUT', style: TextStyle(color: Colors.red)),
onPressed: () { onPressed: () {
// You should do something with the result of the dialog prompt in a // You should do something with the result of the dialog prompt in a
@ -189,11 +189,11 @@ class LogOutButton extends StatelessWidget {
title: Text('Log out?'), title: Text('Log out?'),
content: _logoutMessage, content: _logoutMessage,
actions: [ actions: [
FlatButton( TextButton(
child: const Text('Got it'), child: const Text('Got it'),
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
), ),
FlatButton( TextButton(
child: const Text('Cancel'), child: const Text('Cancel'),
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
), ),

@ -309,11 +309,11 @@ void showChoices(BuildContext context, List<String> choices) {
}, },
), ),
actions: [ actions: [
FlatButton( TextButton(
child: Text('OK'), child: Text('OK'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
FlatButton( TextButton(
child: Text('CANCEL'), child: Text('CANCEL'),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),

@ -64,7 +64,7 @@ class _HomePageState extends State<HomePage> {
style: Theme.of(context).textTheme.subtitle2, style: Theme.of(context).textTheme.subtitle2,
), ),
SizedBox(height: 18), SizedBox(height: 18),
RaisedButton( ElevatedButton(
child: const Text('Continue in iOS view'), child: const Text('Continue in iOS view'),
onPressed: _launchPlatformCount, onPressed: _launchPlatformCount,
), ),

@ -83,12 +83,12 @@ class _CartTotal extends StatelessWidget {
builder: (context, cart, child) => builder: (context, cart, child) =>
Text('\$${cart.totalPrice}', style: hugeStyle)), Text('\$${cart.totalPrice}', style: hugeStyle)),
SizedBox(width: 24), SizedBox(width: 24),
FlatButton( TextButton(
onPressed: () { onPressed: () {
Scaffold.of(context).showSnackBar( Scaffold.of(context).showSnackBar(
SnackBar(content: Text('Buying not supported yet.'))); SnackBar(content: Text('Buying not supported yet.')));
}, },
color: Colors.white, style: TextButton.styleFrom(primary: Colors.white),
child: Text('BUY'), child: Text('BUY'),
), ),
], ],

@ -43,7 +43,7 @@ class _AddButton extends StatelessWidget {
(cart) => cart.items.contains(item), (cart) => cart.items.contains(item),
); );
return FlatButton( return TextButton(
onPressed: isInCart onPressed: isInCart
? null ? null
: () { : () {
@ -54,7 +54,14 @@ class _AddButton extends StatelessWidget {
var cart = context.read<CartModel>(); var cart = context.read<CartModel>();
cart.add(item); cart.add(item);
}, },
splashColor: Theme.of(context).primaryColor, style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((states) {
if (states.contains(MaterialState.pressed)) {
return Theme.of(context).primaryColor;
}
return null; // Defer to the widget's default.
}),
),
child: isInCart ? Icon(Icons.check, semanticLabel: 'ADDED') : Text('ADD'), child: isInCart ? Icon(Icons.check, semanticLabel: 'ADDED') : Text('ADD'),
); );
} }

@ -32,12 +32,14 @@ class MyLogin extends StatelessWidget {
SizedBox( SizedBox(
height: 24, height: 24,
), ),
RaisedButton( ElevatedButton(
color: Colors.yellow,
child: Text('ENTER'), child: Text('ENTER'),
onPressed: () { onPressed: () {
Navigator.pushReplacementNamed(context, '/catalog'); Navigator.pushReplacementNamed(context, '/catalog');
}, },
style: ElevatedButton.styleFrom(
primary: Colors.yellow,
),
) )
], ],
), ),

@ -48,7 +48,7 @@ void main() {
expect(find.text('ADD'), findsWidgets); expect(find.text('ADD'), findsWidgets);
// Performing the click on the ADD button of the first item in the list. // Performing the click on the ADD button of the first item in the list.
await tester.tap(find.widgetWithText(FlatButton, 'ADD').first); await tester.tap(find.widgetWithText(TextButton, 'ADD').first);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Verifying if the tapped ADD button has changed to the check icon. // Verifying if the tapped ADD button has changed to the check icon.

@ -16,8 +16,8 @@ class HomePage extends StatelessWidget {
appBar: AppBar( appBar: AppBar(
title: Text('Testing Sample'), title: Text('Testing Sample'),
actions: <Widget>[ actions: <Widget>[
FlatButton.icon( TextButton.icon(
textColor: Colors.white, style: TextButton.styleFrom(primary: Colors.white),
onPressed: () { onPressed: () {
Navigator.pushNamed(context, FavoritesPage.routeName); Navigator.pushNamed(context, FavoritesPage.routeName);
}, },

@ -119,7 +119,7 @@ class TM extends State<App> {
child: Container( child: Container(
child: CustomPaint( child: CustomPaint(
painter: P(), painter: P(),
child: FlatButton( child: TextButton(
onPressed: press, onPressed: press,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,

@ -512,11 +512,11 @@ class _NumberPickerDialogControllerState extends State<NumberPickerDialog> {
titlePadding: widget.titlePadding, titlePadding: widget.titlePadding,
content: _buildNumberPicker(), content: _buildNumberPicker(),
actions: [ actions: [
new FlatButton( new TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
child: widget.cancelWidget, child: widget.cancelWidget,
), ),
new FlatButton( new TextButton(
onPressed: () => Navigator.of(context).pop(widget.decimalPlaces > 0 onPressed: () => Navigator.of(context).pop(widget.decimalPlaces > 0
? selectedDoubleValue ? selectedDoubleValue
: selectedIntValue), : selectedIntValue),

Loading…
Cancel
Save