Alert Dialog box in Flutter Last Updated : 28 Feb, 2025 Comments Improve Suggest changes Like Article Like Report Alert Dialog box informs the user about the situation that requires acknowledgment. Alert Box is a prompt that takes user confirmation. The very basic use of the alert box is used when we close the app, usually, we are notified with a prompt whether we want to exit or not. That's an alert box.The below-added code shows how to perform alert Dialog box in flutter. I have used a button (Elevated Button in flutter ) to trigger the alert dialog box. In its onPressed property, we have to use the showDialog widget of flutter. It takes context and a builder. In builder, we provide the AlertDialog widget with title, content(Description of a title), and actions (Yes or no buttons), and our alert dialog box is ready to use.Key Properties of Alter Dialog BoxPropertyDescriptionactionsThe set of actions that are displayed at the bottom of the dialog boxtitleThe title of the dialog is displayed in a large font at the top of the dialogcontentThis gives a message/ description about the title which you have provided to the Alert Dialog boxbackgroundColorIt provides the background color to the widget which is being used inelevationElevation provided height to the widget, It gives a default shadow to the widgetFlutter provides its own show Dialog widget which is used to show Dialog box.Example: Dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const MaterialApp( home: HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override // ignore: library_private_types_in_public_api _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("GeeksForGeeks"), foregroundColor: Colors.white, backgroundColor: Colors.green, ), body: Center( child: ElevatedButton( style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0), ), ), onPressed: () { // Show an alert dialog when the button is pressed showDialog( context: context, builder: (ctx) => AlertDialog( title: const Text("Alert Dialog Box"), content: const Text("You have raised an Alert Dialog Box"), actions: <Widget>[ TextButton( onPressed: () { Navigator.of(ctx).pop(); }, child: const Text("okay"), ), ], ), ); }, child: const Text("Show alert Dialog box"), ), ), ); } } Output: Comment More infoAdvertise with us Next Article Alert Dialog box in Flutter A AkashDubey3 Follow Improve Article Tags : Software Engineering Dart Flutter Android Flutter Flutter UI-components +2 More Similar Reads Flutter - Dialogs The dialog is a type of widget which comes on the window or the screen which contains any critical information or can ask for any decision. When a dialog box is popped up all the other functions get disabled until you close the dialog box or provide an answer. We use a dialog box for a different typ 5 min read Flutter - Animated AlertDialog in Flutter Animating an AlertDialog in Flutter involves using the Flutter animations framework to create custom animations for showing and hiding the dialogue. In this article, we are going to add an animation to an AlertDialog. A sample video is given below to get an idea about what we are going to do in this 4 min read Flutter - Giffy Dialogs Giffy Dialogs is a highly customizable alert dialog box. It is implemented through the use of giffy_dialog package from flutter. This package is entirely written in Dart language and provides a wide range of features. There are three types of giffy dialogs listed below: Network giffy dialogFlare gif 5 min read Flutter - Display a GridView Within an AlertDialog Box AlertDialogs are useful Widgets in Flutter to attract the user's attention to a particular message that is shown by the Alert Dialogs. GridViews are efficient widgets to display items in a grid-like structure. To implement a GridView inside an AlertDialog in Flutter, you can create a custom dialog c 7 min read Flutter - Toggle the Visibility of an Alert Dialog Alert Dialog is a very useful way to grab user interactions, here we use the Offstage widget to toggle (Hide/Show) the visibility of the Alert Dialog. The Offstage widget in Flutter is used to hide a widget from the user interface. It does this by laying out the child widget as if it was in the tree 4 min read Like