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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With