import 'package:flutter/material.dart'; import 'dart:async'; void main() { runApp(MaterialApp( home: MyApp(), )); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { Future showdialog(BuildContext context, String message) async { return showDialog( context: context, child: new AlertDialog( title: new Text(message), actions: [ new FlatButton( onPressed: () => Navigator.pop(context), child: new Text("OK")) ], )); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Alert Dialog"), ), body: Center( child: RaisedButton( child: Text( "Click Me", style: TextStyle(color: Colors.white), ), onPressed: () { showdialog(context, "Welcome To Tutor Joes"); }, color: Colors.blue, ), )); } }