Alert Dialog in Flutter

Here is the simple program How to use Aler Dialog widget in Flutter.

Source Code

import 'package:flutter/material.dart';
import 'dart:async';

void main() {
    home: MyApp(),

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  Future showdialog(BuildContext context, String message) async {
    return showDialog(
        context: context,
        child: new AlertDialog(
          title: new Text(message),
          actions: <Widget>[
            new FlatButton(
                onPressed: () => Navigator.pop(context), child: new Text("OK"))

  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");
To download raw file Click Here

Learn All in Tamil © Designed & Developed By Tutor Joes