Reputation: 201
I created a new project and wrote some code in visual studio code.
Here is my source code :
import 'package:flutter/material.dart';
class Raisedbutton extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: "Raised Button",
home: Scaffold(
appBar: AppBar(
title: Text("Latihan membuat Raised button"),
backgroundColor: Colors.green),
body: Center(
child: Column(
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
Text("1. Pizza"),
Text("2. Satay"),
Text("3. Spagethi"),
],
),
),
],
),
),
),
);
}
}
class Raised extends StatelessWidget {
Widget build(BuildContext context) {
var button = Container(
margin: EdgeInsets.only(top: 50.0),
child: RaisedButton(
child: Text("Click here"),
color: Colors.blue,
elevation: 5.0,
onPressed: () {
order(context);
}),
);
}
void order(BuildContext context) {
var alert = AlertDialog(title:Text("CONGRATULATION", style: TextStyle(color: Colors.white, fontSize: 25.0),),content: Text("You got ZONK!!!"),);
}
}
And yes, my source code which is RaisedButton
got an error.
How can I fix that? thanks for your help!
Upvotes: 20
Views: 52482
Reputation: 1
as suggest by Remy, replace it with materialbutton works for me. as my button got many customization, elevatedbutton/outbutton does not work at all, probably need alot of fixing require.
Upvotes: 0
Reputation: 11
Replace RaisedButton
with ElevatedButton
and FlatButton
with TextButton
to resolve the errors.
Upvotes: 0
Reputation: 858
RaisedButton and Flatbutton are now deprecated, but to use the same button configs change to MaterialButton, you wont have to redo your button styling
Upvotes: 2
Reputation: 31
RaisedButton is now deprecated. you can use ElevatedButton instead. check more here https://educity.app/flutter/create-a-button-with-border-radius
Upvotes: 3
Reputation: 129
RaisedButton is now deprecated.
use ElevatedButton instead of RaisedButton
Upvotes: 13
Reputation: 6729
RaisedButton is now deprecated and replaced by ElevatedButton. Based on the documentation:
FlatButton, RaisedButton, and OutlineButton have been replaced by TextButton, ElevatedButton, and OutlinedButton respectively. ButtonTheme has been replaced by TextButtonTheme, ElevatedButtonTheme, and OutlinedButtonTheme. The original classes will eventually be removed, please migrate code that uses them. There's a detailed migration guide for the new button and button theme classes in flutter.dev/go/material-button-migration-guide.
Upvotes: 53