📱
Material Alert Dialogs for Flutter A new Flutter package project.
Getting Started
This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
🥰
Attractive,
🎨
stylish Material Dialog in Flutter easily.
Flutter package to implement animated, 1. Material Dialog | 2. Animated Material Dialog |
---|---|
Introduction
MaterialAlerDialog library is built upon Flutter Material Design library. This API will be useful to create rich, animated, beautiful dialogs in Flutter easily.
Implementation
Implementation of Material Alert Dialog library is so easy. You can check /app directory for demo. Let's have look on basic steps of implementation.
Use this package as library
1.Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
material_alertdialog: ^0.0.1
2. Install it
You can install packages from the command line:
$ flutter pub get
Alternatively, your editor might support flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:material_alertdialog/material_alertdialog.dart';
Create AlertDialog Instance
As there are two types of dialogs in library. Material Dialogs are instantiated as follows.
i. MaterialAlertDialog
MaterialDialog
class is used to create MaterialAlertDialog. Its static Builder
class is used to instantiate it.
showDialog(context: context, builder:(context)=>
MaterialAlertDialog(
height: 250,
title: "Exit",
message: "Are you sure you want to quit",
onPresedPositiveButton: (){
//add what you want for navigate
},
onPresedNegativeButton: (){
Navigator.pop(context);
},
),
);
ii. AnimatedMaterialAlertDialog
AnimatedMaterialAlertDialog
class is used to create MaterialAlertDialog. Its static Builder
class is used to instantiate it.
showDialog(context: context, builder:(context)=>
AnimatedMaterialAlertDialog(
imagePath: "assets/steth.jpg"
height: 250,
title: "Exit",
message: "Are you sure you want to quit",
onPresedPositiveButton: (){
//add what you want for navigate
},
onPresedNegativeButton: (){
Navigator.pop(context);
},
),
);
Credits
This library is built using following open-source libraries.
- [Material Components for Flutter]
- Material Dialog - Android - By Shreays Patil