Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.

Get Started Now!

How to Make a Confirm Dialog in Flutter

A confirm dialog is a dialog box that asks users to approve the requested operation. It usually appears with button pairs like Yes/No, OK/Cancel, Agree/Disagree. Confirm dialogs help prevent accidental actions such as deleting content, closing an account, leaving a page when the form content on that page has not been saved, etc.

This article shows you how to creat confirm dialogs in Flutter. We will go over 2 examples: the first one demonstrates a material confirm dialog and the second one displays a Cupertino (iOS-style) confirm dialog.

Material Confirm Dialog

If you are developing an app for both Android and iOS and doesn’t need an iOS-exclusive experience, using material is a good way to go.

Preview

Our sample app has a button and a red box. When the button is pressed, a confirm dialog will show up.

  • f the user select “Yes”, the box will be removed then the dialog will be closed. The button then becomes disable.
  • If the user select “No”, the dialog will be closed and nothing else happens.

The code

The complete code with explanations:

Cupertino Confirm Dialog

Preview

The code

Don’t forget to import the Cupertino library:

import ‘package:flutter/cupertino.dart’;

The full code for the xample:

Related Posts

I am getting error “cmdline-tools component is missing” after installing Flutter and Android Studio… I added the Android SDK. How can I solve them?

Solution: Step 1: I fixed the problem by opening Android Studio. Step 2: Click to More Actions. Step 3: Then click on ‘SDK Manager’. Step 4: In Read More

Read More

What is Flutter? & How it is Better than it’s Counterparts? – Cross Platform

What is Flutter? Flutter is an open-source UI software development kit created by Google. It’s used to develop cross-platform applications for Android, iOS, Linux, Mac, Windows, Google Read More

Read More

Creating Your First Flutter Project: A Step-by-Step Guide

Creating your first Flutter project is an exciting journey into mobile app development. Here’s a step-by-step guide to help you get started: 1. Install Flutter Before you Read More

Read More

What is flutter and How Flutter Works & Architecture

What is flutter? Flutter is an open-source UI software development kit created by Google. It is used to build natively compiled applications for mobile, web, and desktop Read More

Read More

Execution failed for task’:app:processDebugGoogleServices’.> No matching client found for package name’com.cotocus.holidaylandmark.publisher.holidaylandmark_publisher’ android studio-SOLVED

What went wrong: Execution failed for task ‘:app:processDebugGoogleServices’. No matching client found for package name ‘com.example.myapp ‘ Step -1: check your google-services.json and build.gradle matching applicationId and Read More

Read More

Flutter Basic Query

Flutter Widgets Hello World Example Types of Widget We can split the Flutter widget into two categories: Visible (Output and Input) Invisible (Layout and Control) Visible widget Read More

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x