Flutter Raised and Alert Dialogue

First of all you need to create a Column or a row and in that column call the function as AlertBox then the below code will work,
class AlertBox extends StatelessWidget {
const AlertBox({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
height: 80.0,
width: 150.0,
child: RaisedButton(
color: Colors.deepOrange,
child: Text(
"Subscribe",
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontFamily: 'Raleway',
),
),
elevation: 6.0,
onPressed: () {
Showtext(context);
},
),
);
}
void Showtext(BuildContext context) {
var alertDialog = AlertDialog(
title: Text("freecodeit"),
content: Text("Subscribed Sucessfully"),
);
showDialog(
context: context,
builder: (BuildContext context) {
return alertDialog;
});
}
}

0 Comments