1678803897
simple_loading_dialog
A simple full-screen loading dialog for Flutter.
To use this package, add simple_loading_dialog as a dependency in your pubspec.yaml file.
To show the dialog, use the showSimpleLoadingDialog function.
final result = showSimpleLoadingDialog<String>(
context: context,
future: myFutureFunction,
);
This will show a full-screen loading dialog while waiting for the myFutureFunction to complete.
The appearance of the dialog can be customized by passing a dialogBuilder.
showSimpleLoadingDialog<void>(
context: context,
future: myFutureFunction,
dialogBuilder: (context) => AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('Custom message'),
],
),
),
);
If an error occurs while waiting for the Future to complete, the exception will be rethrown. To handle the error, use a try-catch block.
try {
await showSimpleLoadingDialog<void>(
context: context,
future: myFutureFunction,
);
} catch (e) {
// Handle the error.
}
This package is licensed under the MIT License. See the LICENSE file for details.
Run this command:
With Flutter:
$ flutter pub add simple_loading_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
simple_loading_dialog: ^0.1.0
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:simple_loading_dialog/simple_loading_dialog.dart';
import 'package:flutter/material.dart';
import 'package:simple_loading_dialog/simple_loading_dialog.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Simple Loading Dialog Demo',
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.blue,
),
home: const DemoPage(),
);
}
}
class DemoPage extends StatelessWidget {
const DemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Simple Loading Dialog Demo'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Success case
ElevatedButton(
onPressed: () async {
final result = await showSimpleLoadingDialog<String>(
context: context,
future: () async {
await Future<void>.delayed(const Duration(seconds: 1));
return 'Hello';
},
);
// TODO(K9i-0): check context.mounted
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Success result: $result'),
),
);
},
child: const Text('Show loading dialog'),
),
const SizedBox(
height: 32,
),
// Error case
ElevatedButton(
onPressed: () async {
try {
final result = await showSimpleLoadingDialog<String>(
context: context,
future: () async {
await Future<void>.delayed(const Duration(seconds: 1));
throw Exception('Error');
},
);
// TODO(K9i-0): check context.mounted
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Success result: $result'),
duration: const Duration(milliseconds: 500),
),
);
} catch (e) {
// TODO(K9i-0): check context.mounted
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Failed result: $e'),
duration: const Duration(milliseconds: 500),
),
);
}
},
child: const Text('Show loading dialog with error'),
),
const SizedBox(
height: 32,
),
// Custom dialog
ElevatedButton(
onPressed: () async {
final result = await showSimpleLoadingDialog<String>(
context: context,
future: () async {
await Future<void>.delayed(const Duration(seconds: 1));
return 'World';
},
// Custom dialog
dialogBuilder: (context) {
return AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
children: const [
SizedBox(height: 16),
CircularProgressIndicator(),
SizedBox(height: 16),
Text('Loading...'),
SizedBox(height: 16),
],
),
);
},
);
// TODO(K9i-0): check context.mounted
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Success result: $result'),
duration: const Duration(milliseconds: 500),
),
);
},
child: const Text('Show loading dialog with custom dialog'),
),
],
),
),
);
}
}
Download Details:
Author: K9i-0
Source Code: https://github.com/K9i-0/simple_loading_dialog
1675617086
Emerge Alert Dialog
An emerge alert dialog package is allows developers to easily create and display alert dialogs with custom animations. Emerge dialogs are used to display important information or messages to the user and often include a call to action, such as a button to confirm or dismiss the dialog.
In the context of the Emerge framework, an Alert Dialog is a type of dialog box that can be used to display an alert message or to prompt the user for a response within the context of an Emerge application.
To use this package :
dependencies:
emerge_alert_dialog: ^0.0.3
Future<void> _showMyDialog(BuildContext context) async {
return showDialog<void>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return EmergeAlertDialog(
alignment: Alignment.bottomCenter,
emergeAlertDialogOptions: EmergeAlertDialogOptions(
title: const Text("Privacy Info"),
),
);
},
);
}
![]() | ![]() |
Run this command:
With Flutter:
$ flutter pub add emerge_alert_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
emerge_alert_dialog: ^0.0.3
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:emerge_alert_dialog/emerge_alert_dialog.dart';
import 'package:emerge_pop_up_example/home_screen.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Emerge Alert Dialog',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: const HomeScreen(),
);
}
}
Download Details:
Author: champ96k
Source Code: https://github.com/champ96k/emerge_alert_dialog
1675616537
dim_loading_dialog
Customizable progress dialog for Flutter applications with smooth animation for background dim color and blur.
Add dependency to pubspec.yaml file :dim_loading_dialog: 0.0.1
Run this command :$ flutter pub get
Import class in your project :import 'package:dim_loading_dialog/dim_loading_dialog.dart';
DimLoadingDialog dimDialog = DimLoadingDialog(
GlobalVariable.navState.currentState!.context,
blur: 2,
backgroundColor: const Color(0x33000000),
animationDuration: const Duration(milliseconds: 500));
dimDialog.show(); // show dialog
dimDialog.dismiss(); //close dialog
DimLoadingDialog customdimDialog = DimLoadingDialog(
context,
blur: 2,
backgroundColor: Color(0x33000000),
loadingWidget: Container(
width: 150,
height: 150,
color: Colors.red,
child: CircularProgressIndicator(),
));
Name | Type | Description | Default |
---|---|---|---|
backgroundColor | Color | Dialog dim(background) Color | Color (0x99000000) |
blur | double | Blur amount of dialog background | 0 |
dismissable | bool | Setting this true lets user dismiss dialog by touching outside of it. | true |
onDismiss | Function | This function triggers when user dismisses dialog. | - |
loadingWidget | Widget | Dialog's widget. You can use your own widget when showing dialog. | simple widget |
useSafeArea | bool | Setting this to false makes dialog background fullscreen but when you set it true blur and background color will not apply on status bar, navigation bar and ... | false |
animationDuration | Duration | This duration defines how much will take for blur and background color to appear. | Duration (milliseconds : 300) |
Run this command:
With Flutter:
$ flutter pub add dim_loading_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
dim_loading_dialog: ^0.0.1
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:dim_loading_dialog/dim_loading_dialog.dart';
import 'package:dim_loading_dialog_example/home.dart';
import 'package:flutter/material.dart';
import 'package:dim_loading_dialog/dim_loading_dialog.dart';
class GlobalVariable {
/// This global key is used in material app for navigation through firebase notifications.
/// [navState] usage can be found in [notification_notifier.dart] file.
static final GlobalKey<NavigatorState> navState = GlobalKey<NavigatorState>();
}
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: GlobalVariable.navState,
home: const HomePage(),
theme: ThemeData(
// We set Poppins as our default font
// textTheme: GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme),
primaryColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
);
}
}
Download Details:
Author: MrHafid
Source Code: https://github.com/MrHafid/dim_loading_dialog_flutter
1675578336
progress_dialog
A light weight package to show progress dialog. As it is a stateful widget, you can change the text shown on the dialog dynamically.
Thank you for being a user of this package, this package is discontinued due to serveral reasons, please find the other library which you can use to accomplish the task which this package does and I believe that package will be more helpful. Please find the repo link here for OTS (Over the screen)
Dart SDK version >= 2.7.0
Add the Package
dependencies:
progress_dialog: ^1.2.4
Import the package in your dart file
import 'package:progress_dialog/progress_dialog.dart';
Create and initialise a ProgressDialog object inside the build() method passing context to it
final ProgressDialog pr = ProgressDialog(context);
//For normal dialog
pr = ProgressDialog(context,type: ProgressDialogType.Normal, isDismissible: true/false, showLogs: true/false);
//For showing progress percentage
pr = ProgressDialog(context,type: ProgressDialogType.Download, isDismissible: true/false, showLogs: true/false);
pr.style(
message: 'Downloading file...',
borderRadius: 10.0,
backgroundColor: Colors.white,
progressWidget: CircularProgressIndicator(),
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
textDirection: TextDirection.rtl,
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600)
);
Note: You don't need to use all parameters, all of them are optional
await pr.show();
pr.update(
progress: 50.0,
message: "Please wait...",
progressWidget: Container(
padding: EdgeInsets.all(8.0), child: CircularProgressIndicator()),
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),
);
Note: You don't need to use all parameters, all of them are optional
pr.hide().then((isHidden) {
print(isHidden);
});
// or
await pr.hide();
Navigating to next screens must be done after the completion of Future - hide(). See here for example
bool isProgressDialogShowing = pr.isShowing();
print(isProgressDialogShowing);
pr = ProgressDialog(
context,
type: ProgressDialogType.Normal,
isDismissible: true,
/// your body here
customBody: LinearProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
backgroundColor: Colors.white,
),
);
If you don't like to configure/style the dialog and continue with the default style, it's okay but just have a look at our default configuration.
Attribute | Value |
---|---|
Dismissible | true |
ProgressDialogType | ProgressDialogType.Normal |
BackgroundColor | Colors.white |
BorderRadius | RoundedRectangularBorder(radius: 8.0) |
AnimationCurve | Curves.easeInOut |
Elevation | 8.0 |
ProgressWidget | Double_rings_loding_indicator |
MessageTextStyle | color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600 |
ProgressTextStyle | color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400 |
showLogs | false |
Attribute | Can be updated during instantiating | Can be updated during styling | Can be updated during dialog is shown |
---|---|---|---|
Dismissible | Yes | No | No |
ProgressDialogType | Yes | No | No |
BackgroundColor | No | Yes | No |
BorderRadius | No | Yes | No |
AnimationCurve | No | Yes | No |
Elevation | No | Yes | No |
ProgressWidget | No | Yes | Yes |
MessageTextStyle | No | Yes | Yes |
ProgressTextStyle | No | Yes | Yes |
ShowLogs | Yes | No | No |
Pull requests and issues are always welcome!
Loading indicator -> https://loading.io/
Run this command:
With Flutter:
$ flutter pub add progress_dialog_fork
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
progress_dialog_fork: ^1.0.0
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:progress_dialog_fork/progress_dialog_fork.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:progress_dialog_fork/progress_dialog_fork.dart';
//import '../../lib/progress_dialog.dart';
ProgressDialog pr;
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatelessWidget {
double percentage = 0.0;
@override
Widget build(BuildContext context) {
// pr = new ProgressDialog(context,
// type: ProgressDialogType.Normal, isDismissible: false);
// pr = new ProgressDialog(context, type: ProgressDialogType.Download);
// Custom body test
pr = ProgressDialog(
context,
type: ProgressDialogType.Download,
textDirection: TextDirection.rtl,
isDismissible: true,
// customBody: LinearProgressIndicator(
// valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
// backgroundColor: Colors.white,
// ),
);
pr.style(
// message: 'Downloading file...',
message:
'Lets dump some huge text into the progress dialog and check whether it can handle the huge text. If it works then not you or me, flutter is awesome',
borderRadius: 10.0,
backgroundColor: Colors.white,
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
progressWidgetAlignment: Alignment.center,
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),
);
return Scaffold(
body: Center(
child: ElevatedButton(
child: Text(
'Show Dialog',
style: TextStyle(color: Colors.white),
),
//color: Colors.blue,
onPressed: () async {
await pr.show();
Future.delayed(Duration(seconds: 2)).then((onvalue) {
percentage = percentage + 30.0;
print(percentage);
pr.update(
progress: percentage,
message: "Please wait...",
progressWidget: Container(
padding: EdgeInsets.all(8.0),
child: CircularProgressIndicator()),
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black,
fontSize: 13.0,
fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black,
fontSize: 19.0,
fontWeight: FontWeight.w600),
);
Future.delayed(Duration(seconds: 2)).then((value) {
percentage = percentage + 30.0;
pr.update(
progress: percentage, message: "Few more seconds...");
print(percentage);
Future.delayed(Duration(seconds: 2)).then((value) {
percentage = percentage + 30.0;
pr.update(progress: percentage, message: "Almost done...");
print(percentage);
Future.delayed(Duration(seconds: 2)).then((value) {
pr.hide().whenComplete(() {
print(pr.isShowing());
});
percentage = 0.0;
});
});
});
});
Future.delayed(Duration(seconds: 10)).then((onValue) {
print("PR status ${pr.isShowing()}");
if (pr.isShowing())
pr.hide().then((isHidden) {
print(isHidden);
});
print("PR status ${pr.isShowing()}");
});
}),
),
);
}
}
class FirstScreen extends StatefulWidget {
@override
_FirstScreenState createState() => _FirstScreenState();
}
class _FirstScreenState extends State<FirstScreen> {
ProgressDialog pr;
@override
Widget build(BuildContext context) {
pr = new ProgressDialog(context, showLogs: true);
pr.style(message: 'Please wait...');
return Scaffold(
body: Center(
child: ElevatedButton(
child: Text('Show dialog and go to next screen',
style: TextStyle(color: Colors.white)),
//color: Colors.blueAccent,
onPressed: () {
pr.show();
Future.delayed(Duration(seconds: 3)).then((value) {
pr.hide().whenComplete(() {
Navigator.of(context).push(CupertinoPageRoute(
builder: (BuildContext context) => SecondScreen()));
});
});
},
),
),
);
}
}
class SecondScreen extends StatefulWidget {
@override
_SecondScreenState createState() => _SecondScreenState();
}
class _SecondScreenState extends State<SecondScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: Text('I am second screen')),
);
}
}
Download Details:
Author: Donzo24
Source Code: https://github.com/Donzo24/progress_dialog_fork
1675528285
simple_confirm
简洁的确认探出窗
Run this command:
With Flutter:
$ flutter pub add simple_confirm
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
simple_confirm: ^0.0.1
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:simple_confirm/simple_confirm.dart';
import 'package:flutter/material.dart';
import 'package:simple_confirm/simple_confirm.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
final SimpleConfirmOptions options = SimpleConfirmOptions(
content: "提醒内容提醒内容提醒内容提醒内容提醒内容提醒内容提醒内容提醒内容提醒内容",
title: "标题",
confirmText: "确定",
cancelText: "取消",
onCancel: () {},
onConfirm: () {});
SimpleConfirm.show(context, options: options);
},
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Download Details:
Author:
Source Code: https://pub.dev/packages/simple_confirm
1670513426
slide_popup_dialog_null_safety
Popup dialog with slide mechanism. Use it like AlertDialog or SimpleDialog.
Add slide_popup_dialog_null_safety to your package's pubspec.yaml, then intall it.
Import package.
import 'package:slide_popup_dialog_null_safety/slide_popup_dialog.dart' as slideDialog;
void _showDialog() {
slideDialog.showSlideDialog(
context: context,
child: Text("Hello World"),
);
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({Key key, this.title}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: RaisedButton(
child: Text("Press to open dialog"),
onPressed: _showDialog,
),
),
);
}
void _showDialog() {
slideDialog.showSlideDialog(
context: context,
child: Text("Hello World"),
barrierColor: Colors.white.withOpacity(0.7),
pillColor: Colors.red,
backgroundColor: Colors.yellow,
);
}
}
Run this command:
With Flutter:
$ flutter pub add slide_popup_dialog_null_safety
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
slide_popup_dialog_null_safety: ^1.0.0
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:slide_popup_dialog_null_safety/pill_gesture.dart';
import 'package:slide_popup_dialog_null_safety/slide_dialog.dart';
import 'package:slide_popup_dialog_null_safety/slide_popup_dialog.dart';
import 'package:flutter/material.dart';
import 'package:slide_popup_dialog_null_safety/slide_popup_dialog.dart' as slideDialog;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Slide Dialog Demo',
home: MyHomePage(title: 'Slide Dialog Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({Key? key, required this.title}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: RaisedButton(
child: Text("Press to open dialog"),
onPressed: _showDialog,
),
),
);
}
void _showDialog() {
slideDialog.showSlideDialog(
context: context,
child: Text("Hello World"),
// barrierColor: Colors.white.withOpacity(0.7),
// pillColor: Colors.red,
// backgroundColor: Colors.yellow,
);
}
}
Download Details:
Author: mahmut
Source Code: https://github.com/mahmut/slide_popup_dialog
1668134460
Currently in SwiftUI, the only way to inform the user about some process that finished for example, is by using Alert
. Sometimes, you just want to pop a message that tells the user that something completed, or his message was sent. Apple doesn't provide any other method rather than using Alert
even though Apple using all kinds of different pop-ups. The results are poor UX where the user would need to tap "OK/Dismiss" for every little information that he should be notified about.
Alert Toast is an open-source library in Github to use with SwiftUI. It allows you to present popups that don't need any user action to dismiss or to validate. Some great usage examples: Message Sent
, Poor Network Connection
, Profile Updated
, Logged In/Out
, Favorited
, Loading
and so on…
Alert
(pop at the center), HUD
(drop from the top) and Banner
(pop/slide from the bottom).Complete
, Error
SystemImage
, Image
, Loading
, and Regular
(Only Text).put star 🌟
.CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate AlertToast
into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'AlertToast'
The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
To integrate AlertToast
into your Xcode project using Xcode 12, specify it in File > Swift Packages > Add Package Dependency...
:
https://github.com/elai950/AlertToast.git, :branch="master"
For Xcode 13, please refer this article to install AlertToast
If you prefer not to use any of dependency managers, you can integrate AlertToast
into your project manually. Put Sources/AlertToast
folder in your Xcode project. Make sure to enable Copy items if needed
and Create groups
.
First, add import AlertToast
on every swift
file you would like to use AlertToast
.
Then, use the .toast
view modifier:
Parameters:
isPresenting
: (MUST) assign a Binding<Bool>
to show or dismiss alert.duration
: default is 2, set 0 to disable auto dismiss.tapToDismiss
: default is true
, set false
to disable.alert
: (MUST) expects AlertToast
.import AlertToast
import SwiftUI
struct ContentView: View{
@State private var showToast = false
var body: some View{
VStack{
Button("Show Toast"){
showToast.toggle()
}
}
.toast(isPresenting: $showToast){
// `.alert` is the default displayMode
AlertToast(type: .regular, title: "Message Sent!")
//Choose .hud to toast alert from the top of the screen
//AlertToast(displayMode: .hud, type: .regular, title: "Message Sent!")
//Choose .banner to slide/pop alert from the bottom of the screen
//AlertToast(displayMode: .banner(.slide), type: .regular, title: "Message Sent!")
}
}
}
.toast(isPresenting: $showAlert, duration: 2, tapToDismiss: true, alert: {
//AlertToast goes here
}, onTap: {
//onTap would call either if `tapToDismis` is true/false
//If tapToDismiss is true, onTap would call and then dismis the alert
}, completion: {
//Completion block after dismiss
})
AlertToast(displayMode: DisplayMode,
type: AlertType,
title: Optional(String),
subTitle: Optional(String),
style: Optional(AlertStyle))
//This is the available customizations parameters:
AlertStyle(backgroundColor: Color?,
titleColor: Color?,
subTitleColor: Color?,
titleFont: Font?,
subTitleFont: Font?)
SFSymbols
..toast(isPresenting: Binding<Bool>, duration: Double = 2, tapToDismiss: true, alert: () -> AlertToast , onTap: () -> (), completion: () -> () )
AlertToast(type: .regular, title: Optional(String), subTitle: Optional(String))
AlertToast(type: .complete(Color)/.error(Color), title: Optional(String), subTitle: Optional(String))
AlertToast(type: .systemImage(String, Color), title: Optional(String), subTitle: Optional(String))
AlertToast(type: .image(String), title: Optional(String), subTitle: Optional(String))
//When using loading, duration won't auto dismiss and tapToDismiss is set to false
AlertToast(type: .loading, title: Optional(String), subTitle: Optional(String))
You can add many .toast
on a single view.
I wrote an article that contains more usage examples.
Medium - How to toast an alert in SwiftUI
All issue reports, feature requests, pull requests and GitHub stars are welcomed and much appreciated.
Author: elai950
Source Code: https://github.com/elai950/AlertToast
License: MIT license
1666763880
PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController
, with a beautiful and totally customizable alert that you can use in your iOS app. Enjoy!
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate PMAlertController into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'PMAlertController'
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate PMAlertController into your Xcode project using Carthage, specify it in your Cartfile
:
github "pmusolino/PMAlertController"
Run carthage update
to build the framework and drag the built PMAlertController.framework
into your Xcode project.
/Library
folder in your project.The usage is very similar to UIAlertController
. PMAlertController
has two styles: Alert & Walkthrough.
Alert Style: with this style, the alert has the width of 270 points, like Apple's UIAlertController
.
Walkthrough Style: with walkthrough, the alert has the width of the screen minus 18 points from the left and the right bounds. This mode is intended to be used before authorization requests like the ones for location, push notifications and more.
//This code works with Swift 5
let alertVC = PMAlertController(title: "A Title", description: "My Description", image: UIImage(named: "img.png"), style: .alert)
alertVC.addAction(PMAlertAction(title: "Cancel", style: .cancel, action: { () -> Void in
print("Capture action Cancel")
}))
alertVC.addAction(PMAlertAction(title: "OK", style: .default, action: { () in
print("Capture action OK")
}))
alertVC.addTextField { (textField) in
textField?.placeholder = "Location..."
}
self.present(alertVC, animated: true, completion: nil)
If you use Swift 5.0 or higher, you can use the latest release.
If you use Swift 4, you can use the release 3.5.0.
If you use Swift 3, you can use the release 2.1.3.
If you use Swift 2.3, you can use the release 1.1.0
If you use Swift 2.2, you can use the release 1.0.5
You may now use this library with React Native via the module here
Made with ❤️ by Paolo Musolino.
Follow me on:
Author: pmusolino
Source Code: https://github.com/pmusolino/PMAlertController
License: MIT license
1665916827
cf_dialog_required
A new flutter plugin project.
This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Run this command:
With Flutter:
$ flutter pub add cf_dialog_required
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
cf_dialog_required: ^0.0.1
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:cf_dialog_required/cf_dialog_required.dart';
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:cf_dialog_required/cf_dialog_required.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: const Center(
child: ButtonCircle(child: Icon(Icons.ac_unit),size: 50,),
),
),
);
}
}
Download Details:
Author:
Source Code: https://pub.dev/packages/cf_dialog_required
1665196633
bottom_dialog
Bottom dialog is a picker dialog for pick with single or multiply chooses. with support of adding icons or and search.
List<BottomModel> list = [
BottomModel(
name: 'Camera',
id: 1,
selected: true,
imageWidget: Icon(Icons.camera),
sortId: 1),
BottomModel(
name: 'Gallery',
id: 2,
selected: false,
imageWidget: Icon(Icons.image),
sortId: 1)
];
ShowBottomDialog(
context: context,
bottomModelList: list,
// show or hide image inside list
showImage: true,
// list item text style
itemTextStyle: TextStyle(color: Colors.black87, fontSize: 18.0),
// title text in center of header
titleText: Text(
'Select which',
style: TextStyle(color: Colors.black, fontSize: 22.0),
),
// save word text, only showed when multiSelect = true,
saveWord: 'Save',
// save text style
saveTextStyle: TextStyle(color: Colors.blueAccent, fontSize: 18.0),
// background color
widgetColor: Colors.white,
// allow use search inside dialog
useSearch: true,
// search text
searchWord: 'Search...',
// search text style
searchTextStyle: TextStyle(color: Colors.blueAccent, fontSize: 16.0),
// search hint text style
searchHintTextStyle: TextStyle(color: Colors.grey, fontSize: 16.0),
// custom widget for search icon as prefix
prefixSearchIcon: Icon(
Icons.search,
color: Colors.blueAccent,
),
// if true => return onSave function, else return onItemSelected
multiSelect: true,
onSave: (List<BottomModel> returnedList) {},
// return
onItemSelected: (BottomModel item) {},
// allow to show shadow at top and bottom of dialog
hasShadow: true,
// make custom dialog
customBoxShadow: [
BoxShadow(
color: Colors.blueAccent,
blurRadius: 5.0,
spreadRadius: 5.0,
offset: Offset(2.0, 2.0), // shadow direction: bottom right
)
],
// divider after header (cancel, title text...)
hasDividerAfterHeader: true,
// divider color
dividerColor: Colors.blueGrey,
// cancel text
cancelWord: 'Cancel',
// cancel text style , will throw error if it's null
cancelTextStyle: TextStyle(color: Colors.red, fontSize: 16.0),
// dialog top left and right radius
dialogRadius: 30.0,
);
Run this command:
With Flutter:
$ flutter pub add bottom_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
bottom_dialog: ^1.0.3
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:bottom_dialog/bottom_dialog.dart';
import 'package:bottom_dialog/bottom_model.dart';
import 'package:flutter/material.dart';
import 'package:bottom_dialog/show_bottom_dialog.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Bottom dialog Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Bottom dialog Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'click on floating action button to show dialog',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _showDialog,
tooltip: 'Increment',
child: Text(
'show dialog',
textAlign: TextAlign.center,
),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
void _showDialog() {
List<BottomModel> list = [
BottomModel(
name: 'One',
id: '1',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 1),
BottomModel(
name: 'Two',
id: '2',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 2),
BottomModel(
name: 'Three',
id: '3',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 3),
BottomModel(
name: 'Four',
id: '4',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 4),
BottomModel(
name: 'Five',
id: '5',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 5),
BottomModel(
name: 'Seven',
id: '7',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 7),
BottomModel(
name: 'Six',
id: '6',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 6),
BottomModel(
name: 'Eight',
id: '8',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 8),
BottomModel(
name: 'Nine',
id: '9',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 9),
BottomModel(
name: 'Ten',
id: '10',
selected: false,
imageWidget: Icon(Icons.confirmation_number_sharp),
sortId: 10),
];
ShowBottomDialog(
context: context,
bottomModelList: list,
// show or hide image inside list
showImage: true,
// list item text style
itemTextStyle: TextStyle(color: Colors.black87, fontSize: 18.0),
// title text in center of header
titleText: Text(
'Select which',
style: TextStyle(color: Colors.black, fontSize: 22.0),
),
// save word text, only showed when multiSelect = true,
saveWord: 'Save',
// save text style
saveTextStyle: TextStyle(color: Colors.blueAccent, fontSize: 18.0),
// background color
widgetColor: Colors.white,
// allow use search inside dialog
useSearch: true,
// search text
searchWord: 'Search...',
// search text style
searchTextStyle: TextStyle(color: Colors.blueAccent, fontSize: 16.0),
// search hint text style
searchHintTextStyle: TextStyle(color: Colors.grey, fontSize: 16.0),
// custom widget for search icon as prefix
prefixSearchIcon: Icon(
Icons.search,
color: Colors.blueAccent,
),
// if true => return onSave function, else return onItemSelected
multiSelect: true,
onSave: (List<BottomModel> returnedList) {},
// return
onItemSelected: (BottomModel item) {},
// allow to show shadow at top and bottom of dialog
hasShadow: true,
// make custom dialog
customBoxShadow: [
BoxShadow(
color: Colors.blueAccent,
blurRadius: 5.0,
spreadRadius: 5.0,
offset: Offset(2.0, 2.0), // shadow direction: bottom right
)
],
// divider after header (cancel, title text...)
hasDividerAfterHeader: true,
// divider color
dividerColor: Colors.blueGrey,
// cancel text
cancelWord: 'Cancel',
// cancel text style , will throw error if it's null
cancelTextStyle: TextStyle(color: Colors.red, fontSize: 16.0),
// dialog top left and right radius
dialogRadius: 30.0,
);
}
}
Download Details:
Author: georgesamirmansour
Source Code: https://github.com/georgesamirmansour/bottom_dialog
1664294880
"showDialog()" calling: gets native request to android/ios Consent Form dialog and sets result as boolean:
Bool variable "isForTest" for testing library, set true to activate setDebugGeography. (works only for Android) In release build set false or delete this argument!
"testDeviceId" you can find in logs.
If user already chose one of Consent Form variants and call it a second time:
GdprDialog.instance.showDialog(isForTest: true, testDeviceId: 'xxxxxxxxxxxxxxx')
.then((onValue) {
print('result === $onValue');
});
In the release build, you only does not need a parameters.
GdprDialog.instance.getConsentStatus();
It will return string of consent status:
API, which depends on Android v2 Embedding, can not show you the real status of personalized ad.
Run this command:
With Flutter:
$ flutter pub add gdpr_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
gdpr_dialog: ^2.1.1
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:gdpr_dialog/gdpr_dialog.dart';
import 'package:flutter/material.dart';
import 'package:gdpr_dialog/gdpr_dialog.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String status = 'none';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: <Widget>[
ElevatedButton(
child: Text('Show dialog'),
onPressed: () {
GdprDialog.instance.resetDecision();
GdprDialog.instance.showDialog(isForTest: false, testDeviceId: '').then((onValue) {
setState(() => status = 'dialog result == $onValue');
});
},
),
ElevatedButton(
child: Text('Get consent status'),
onPressed: () => GdprDialog.instance
.getConsentStatus()
.then((value) => setState(() => status = 'consent status == $value')),
),
Container(height: 50),
Text(status),
],
),
),
),
);
}
}
Download Details:
Author: antonmolchan
Source Code: https://github.com/antonmolchan/gdpr_dialog_flutter
1664291157
progress_dialog
A light weight package to show progress dialog. As it is a stateful widget, you can change the text shown on the dialog dynamically.
This is the original package and it's owner https://github.com/fayaz07/progress_dialog
It was discontinued by him, but i really liked the package so I am trynna revive it :D I added null safety and updated most of the stuff making it null safe and useable again :)
Import the package in your dart file
import 'package:progress_dialog/progress_dialog_null_safe.dart';
Create and initialise a ProgressDialog object inside the build() method passing context to it
final ProgressDialog pr = ProgressDialog(context);
//For normal dialog
pr = ProgressDialog(context,type: ProgressDialogType.Normal, isDismissible: true/false, showLogs: true/false);
//For showing progress percentage
pr = ProgressDialog(context,type: ProgressDialogType.Download, isDismissible: true/false, showLogs: true/false);
pr.style(
message: 'Downloading file...',
borderRadius: 10.0,
backgroundColor: Colors.white,
progressWidget: CircularProgressIndicator(),
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
textDirection: TextDirection.rtl,
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600)
);
Note: You don't need to use all parameters, all of them are optional
await pr.show();
pr.update(
progress: 50.0,
message: "Please wait...",
progressWidget: Container(
padding: EdgeInsets.all(8.0), child: CircularProgressIndicator()),
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),
);
Note: You don't need to use all parameters, all of them are optional
pr.hide().then((isHidden) {
print(isHidden);
});
// or
await pr.hide();
Navigating to next screens must be done after the completion of Future - hide(). See here for example
bool isProgressDialogShowing = pr.isShowing();
print(isProgressDialogShowing);
pr = ProgressDialog(
context,
type: ProgressDialogType.Normal,
isDismissible: true,
/// your body here
customBody: LinearProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
backgroundColor: Colors.white,
),
);
If you don't like to configure/style the dialog and continue with the default style, it's okay but just have a look at our default configuration.
Attribute | Value |
---|---|
Dismissible | true |
ProgressDialogType | ProgressDialogType.Normal |
BackgroundColor | Colors.white |
BorderRadius | RoundedRectangularBorder(radius: 8.0) |
AnimationCurve | Curves.easeInOut |
Elevation | 8.0 |
ProgressWidget | Double_rings_loding_indicator |
MessageTextStyle | color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600 |
ProgressTextStyle | color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400 |
showLogs | false |
Attribute | Can be updated during instantiating | Can be updated during styling | Can be updated during dialog is shown |
---|---|---|---|
Dismissible | Yes | No | No |
ProgressDialogType | Yes | No | No |
BackgroundColor | No | Yes | No |
BorderRadius | No | Yes | No |
AnimationCurve | No | Yes | No |
Elevation | No | Yes | No |
ProgressWidget | No | Yes | Yes |
MessageTextStyle | No | Yes | Yes |
ProgressTextStyle | No | Yes | Yes |
ShowLogs | Yes | No | No |
Loading indicator -> https://loading.io/
Run this command:
With Flutter:
$ flutter pub add progress_dialog_null_safe
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
progress_dialog_null_safe: ^1.0.7
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
late ProgressDialog pr;
void main() {
runApp(const MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double percentage = 0.0;
@override
Widget build(context) {
// pr = new ProgressDialog(context,
// type: ProgressDialogType.Normal, isDismissible: false);
// pr = new ProgressDialog(context, type: ProgressDialogType.Download);
// Custom body test
pr = ProgressDialog(
context,
type: ProgressDialogType.download,
textDirection: TextDirection.rtl,
isDismissible: true,
// customBody: LinearProgressIndicator(
// valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
// backgroundColor: Colors.white,
// ),
);
pr.style(
// message: 'Downloading file...',
widgetAboveTheDialog: Text('meow'),
message:
'Lets dump some huge text into the progress dialog and check whether it can handle the huge text. If it works then not you or me, flutter is awesome',
borderRadius: 10.0,
backgroundColor: Colors.white,
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
progressWidgetAlignment: Alignment.center,
maxProgress: 100.0,
progressTextStyle: const TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: const TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),
);
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text(
'Show Dialog',
style: TextStyle(color: Colors.white),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.blue),
),
onPressed: () async {
await pr.show();
Future.delayed(const Duration(seconds: 2)).then((onValue) {
percentage = percentage + 30.0;
print(percentage);
pr.update(
progress: percentage,
message: "Please wait...",
progressWidget: Container(
padding: const EdgeInsets.all(8.0),
child: const CircularProgressIndicator()),
maxProgress: 100.0,
progressTextStyle: const TextStyle(
color: Colors.black,
fontSize: 13.0,
fontWeight: FontWeight.w400),
messageTextStyle: const TextStyle(
color: Colors.black,
fontSize: 19.0,
fontWeight: FontWeight.w600),
);
Future.delayed(const Duration(seconds: 2)).then((value) {
percentage = percentage + 30.0;
pr.update(
progress: percentage, message: "Few more seconds...");
print(percentage);
Future.delayed(const Duration(seconds: 2)).then((value) {
percentage = percentage + 30.0;
pr.update(progress: percentage, message: "Almost done...");
print(percentage);
Future.delayed(const Duration(seconds: 2)).then((value) {
pr.hide().whenComplete(() {
print(pr.isShowing());
});
percentage = 0.0;
});
});
});
});
Future.delayed(const Duration(seconds: 10)).then((onValue) {
print("PR status ${pr.isShowing()}");
if (pr.isShowing()) {
pr.hide().then((isHidden) {
print(isHidden);
});
}
print("PR status ${pr.isShowing()}");
});
}),
),
);
}
}
class FirstScreen extends StatefulWidget {
const FirstScreen({Key? key}) : super(key: key);
@override
_FirstScreenState createState() => _FirstScreenState();
}
class _FirstScreenState extends State<FirstScreen> {
late ProgressDialog pr;
@override
Widget build(context) {
pr = ProgressDialog(context, showLogs: true);
pr.style(message: 'Please wait...');
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text('Show dialog and go to next screen',
style: TextStyle(color: Colors.white)),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.blueAccent),
),
onPressed: () {
pr.show();
Future.delayed(const Duration(seconds: 3)).then((value) {
pr.hide().whenComplete(() {
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => const SecondScreen()));
});
});
},
),
),
);
}
}
class SecondScreen extends StatefulWidget {
const SecondScreen({Key? key}) : super(key: key);
@override
_SecondScreenState createState() => _SecondScreenState();
}
class _SecondScreenState extends State<SecondScreen> {
@override
Widget build(context) {
return const Scaffold(
body: Center(child: Text('I am second screen')),
);
}
}
Download Details:
Author: CodingFries
Source Code: https://github.com/CodingFries/progress_dialog
1662821157
flutter_awesome_alert_box
A new flutter package project which contains lots of beautiful alert dialog that will help you lot to create beautiful awesome alert box very quickly and easily.
Details | Screenshot | Code |
---|---|---|
Diffrent alert boxes | ![]() ![]() | |
Simple Alert Box | ![]() | SimpleAlertBox(context: context); |
Info Alert Box | ![]() | InfoAlertBox(context: context); |
Success Alert Box | ![]() | SuccessAlertBox(context: context); |
Warning Alert Box | ![]() | WarningAlertBox(context: context); |
Danger Alert Box | ![]() | DangerAlertBox(context: context); |
Dark Alert Box | ![]() | DarkAlertBox(context: context); |
Simple Alert Box Center | ![]() | SimpleAlertBoxCenter(context: context); |
Info Alert Box Center | ![]() | InfoAlertBoxCenter(context: context); |
Success Alert Box Center | ![]() | SuccessAlertBoxCenter(context: context); |
Warning Alert Box Center | ![]() | WarningAlertBoxCenter(context: context); |
Danger Alert Box Center | ![]() | DangerAlertBoxCenter(context: context); |
Dark Alert Box Center | ![]() | DarkAlertBoxCenter(context: context); |
Confirm Box | ![]() | ConfirmAlertBox(context: context); |
Confirm Box Dark | ![]() | ConfirmAlertBoxDark(context: context); |
Delete Alert Box | ![]() | DeleteAlertBox(context: context); |
Success Backgroung Alert Box | ![]() | SuccessBgAlertBox(context: context); |
Info Backgroung Alert Box | ![]() | InfoBgAlertBox(context: context); |
Warning Backgroung Alert Box | ![]() | WarningBgAlertBox(context: context); |
Danger Backgroung Alert Box | ![]() | DangerBgAlertBox(context: context); |
Dark Backgroung Alert Box | ![]() | DarkBgAlertBox(context: context); |
Simple Backgroung Alert Box | ![]() | SimpleBgAlertBox(context: context); |
Custom Backgroung Alert Box | ![]() | CustomBgAlertBox(context: context); |
Alert Box Options For SimpleAlertBox,InfoAlertBox,DangerAlert,SuccessAlert,WarningAlert,DarkAlertBox, :
title: [title] used for alert_box title by default its "Your alert title comes here"
icon: [icon] used for alert_box title Icon
messageText: [messageText] used from main message of alert box by default its "Alert Message Here"
titleTextColor: [titleTextColor] used for both title Text and Icon color
messageColor: [messageColor] used for main message text color
buttonColor: [buttonColor] used for button background color
buttonTextColor: [buttonTextColor] used for button text color by default its white
buttonText: [buttonText] used for button text value by default its "Yes"
Alert Box Options For DeleteAlertBox:
title: [title] used for alert_box title by default its "Your alert title comes here"
icon: [icon] used for alert_box title Icon by default its Info icon
messageText: [messageText] used from main message of alert box by default its "Alert Message Here"
titleTextColor: [titleTextColor] used for both title Text and Icon color by default its black
messageColor: [messageColor] used for main message text color by default its black
buttonColorForYes: [buttonColorForYes] used for button background color by default its Green
buttonTextColorForYes: [buttonTextColorForYes] used for button text color by default its white
buttonTextForYes: [buttonTextForYes] used for button text value by default its "Yes"
buttonColorForNo: [buttonColorForNo] used for button background color by default its Red
buttonTextColorForNo: [buttonTextColorForNo] used for button text color by default its white
buttonTextForNo: [buttonTextForNo] used for button text value by default its "No"
onPressedYes: [onPressedYes] is a function that will call when onpressed Yes button
onPressedNo: [onPressedNo] is a function that will call when onpressed No button
Example Code
import 'package:flutter/material.dart';
import 'package:flutter_awesome_alert_box/flutter_awesome_alert_box.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("flutter_awesome_alert_box"),
centerTitle: true,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: FlutterLogo(),
),
),
body: ListView(
children: <Widget>[
Center(child: Text("Simple Alert Box")),
Wrap(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
SimpleAlertBox(context: context);
},
color: Colors.purple,
child: Text(
"Simple",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
InfoAlertBox(context: context);
},
color: Colors.blue,
child: Text(
"Info",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
SuccessAlertBox(context: context);
},
color: Colors.green,
child: Text(
"Success",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DangerAlertBox(context: context);
},
color: Colors.red,
child: Text(
"Danger",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
WarningAlertBox(context: context);
},
color: Colors.orange,
child: Text(
"Warning",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DarkAlertBox(context: context);
},
color: Colors.black,
child: Text(
"Dark",
style: TextStyle(color: Colors.white),
),
),
)
],
),
Center(child: Text("CenterIcon Alert Box")),
Wrap(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
InfoAlertBoxCenter(context: context);
},
color: Colors.blue,
child: Text(
"Info Center",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
SimpleAlertBoxCenter(context: context);
},
color: Colors.blue,
child: Text(
"Simple Center",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
SuccessAlertBoxCenter(context: context);
},
color: Colors.green,
child: Text(
"Suceess Center",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DangerAlertBoxCenter(context: context);
},
color: Colors.red,
child: Text(
"Danger Center",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
WarningAlertBoxCenter(context: context);
},
color: Colors.orange,
child: Text(
"Warning Center",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DarkAlertBoxCenter(context: context);
},
color: Colors.black,
child: Text(
"Dark Center",
style: TextStyle(color: Colors.white),
),
),
),
],
),
SizedBox(
height: 20,
child: Center(child: Text("Confirm Alert Box")),
),
Wrap(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
ConfirmAlertBox(context: context);
},
color: Colors.blue,
child: Text(
"Confirm Box",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
ConfirmAlertBoxDark(context: context);
},
color: Colors.black,
child: Text(
"Confirm Box Dark",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DeleteAlertBox(context: context);
},
color: Colors.red,
child: Text(
"Delete Alert",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
SuccessBgAlertBox(context: context);
},
color: Colors.green,
child: Text(
"Success BG Alert",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DangerBgAlertBox(context: context);
},
color: Colors.red,
child: Text(
"Delete BG Alert",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
WarningBgAlertBox(context: context);
},
color: Colors.orange,
child: Text(
"Warning BG Alert",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
InfoBgAlertBox(context: context);
},
color: Colors.blue,
child: Text(
"Info BG Alert",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
DarkBgAlertBox(context: context);
},
color: Colors.black,
child: Text(
"Dark BG Box",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
SimpleBgAlertBox(context: context);
},
color: Colors.blueAccent,
child: Text(
"Simple BG Box",
style: TextStyle(color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () {
CustomBgAlertBox(context: context);
},
color: Colors.deepOrange,
child: Text(
"Custom BG Box",
style: TextStyle(color: Colors.white),
),
),
)
],
)
],
),
);
}
}
Use this package as a library
Run this command:
With Flutter:
$ flutter pub add flutter_awesome_alert_box
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
flutter_awesome_alert_box: ^2.1.1
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:flutter_awesome_alert_box/flutter_awesome_alert_box.dart';
example/lib/main.dart
import 'package:flutter/material.dart';
import 'home_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "flutter_awesome_alert_box",
theme: ThemeData(
primaryColor: Colors.deepOrange
),
home: HomePage(),
);
}
}
Download Details:
Author:
Source Code: https://pub.dev/packages/flutter_awesome_alert_box
1661523060
Material month picker with layout inspired by this article.
Add mat_month_picker_dialog
to your pubspec.yaml
final selected = await showMonthPicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(1970),
lastDate: DateTime(2050)
);
Year selector | Month selector |
![]() | ![]() |
![]() | ![]() |
Run this command:
With Flutter:
$ flutter pub add mat_month_picker_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
mat_month_picker_dialog: ^1.1.0
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:mat_month_picker_dialog/mat_month_picker_dialog.dart';
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:mat_month_picker_dialog_example/example.dart';
void main() => runApp(const App());
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Month picker example',
home: Example(),
);
}
}
Author: leoshusar
Source Code: https://github.com/leoshusar/mat_month_picker_dialog
License: MIT license
1660770960
A Flutter package for showing platform dialogs without using new routes.

What's the problem?
During project develop we stucks with several problems with Flutter dialogs. This package solves several problems of standart Flutter approach.
showDialog<T>
. It causes problems in case when app handles lifecycle (route) events and relies on calls look like ModalRoute.of(context).isCurrent
. Actually Dialog route becomes active and page route goes background.showDialog<T>
call is asynchronous, there is no straight-forward way to detect if it is really opened. If app needs to open / close several dialogs rapidly, the synchronization mechanism would be tricky.Navigator.of(context).pop()
closes the dialog or the page, which may be confusing.OverlayDialog solves these problems by adding dialog to route overlay, so app navigation and lifecycle becomes easier.
Features
For a complete usage, please see the example.
Alert Dialog instance is created by call DialogWidget.alert(...)
. Additional flags may be set for DialogAction
to highlight Cupertino buttons. These settings doesn't make sense for Material dialogs. Alert dialog is closable by default, this option may be disabled by setting closable
parameter.
DialogWidget.alert(
closable: true,
style: DialogStyle.material,
title: "Title",
content: "Content",
actions: [
DialogAction(
title: "Button One",
handler: buttonOneHandler,
isDestructive: true,
),
DialogAction(
title: "Button Two",
handler: buttonTwoHandler,
isDefault: true,
),
],
)
Progress dialog isn't closable by default and shows circular spinner.
DialogWidget.progress(
style: DialogStyle.material
)
Custom dialog allows to show any widget on gray-out layout.
DialogWidget.custom(
child: widget
)
DialogHelper()
uses to show and hide dialogs. This is singleton instanse so it is no need to keep it inside app variables.
DialogHelper().show(
context,
widget,
)
Dialog customization may be achieved via app theme setup.
ThemeData(
brightness: Brightness.light, // Light or Dark theme
accentColor: Colors.red,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.accent,
),
buttonBarTheme: ButtonBarThemeData(
buttonTextTheme: ButtonTextTheme.accent, // Button style
alignment: MainAxisAlignment.end, // Button position
),
dialogTheme: DialogTheme(
backgroundColor: Colors.blue, // Dialog background
titleTextStyle: TextStyle(color: Colors.green), // Title style
contentTextStyle: TextStyle(color: Colors.purple), // Content style
)
)
Run this command:
With Flutter:
$ flutter pub add overlay_dialog
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
overlay_dialog: ^0.2.1
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:overlay_dialog/overlay_dialog.dart';
example/lib/main.dart
import 'package:example/cupertino_page.dart';
import 'package:example/material_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return AppState();
}
}
class AppState extends State<App> {
bool isMaterial = true;
@override
Widget build(BuildContext context) {
return isMaterial
? _getMaterialApp()
: _getCupertionApp();
}
Widget _getMaterialApp() {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
/// Material dialog theme customization
/*accentColor: Colors.red,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.accent,
),
buttonBarTheme: ButtonBarThemeData(
buttonTextTheme: ButtonTextTheme.accent,
alignment: MainAxisAlignment.end,
),
dialogTheme: DialogTheme(
backgroundColor: Colors.blue,
titleTextStyle: TextStyle(color: Colors.green),
contentTextStyle: TextStyle(color: Colors.purple),
)*/
),
home: MaterialExamplePage(togglePlatform)
);
}
Widget _getCupertionApp() {
return CupertinoApp(
theme: CupertinoThemeData(
brightness: Brightness.light,
),
home: CupertinoExamplePage(togglePlatform)
);
}
void togglePlatform() {
setState(() {
isMaterial = !isMaterial;
});
}
}
This package is actively developed alongside production apps, and the API will change as we continue our way to version 1.0.
Please be fully prepared to deal with breaking changes.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Anastasia Artemyeva (anastasia.artemyeva@orioninc.com)
Author: Mera-company
Source Code: https://github.com/mera-company/flutter-overlay-dialog
License: View license