A Simple Full-screen Loading Dialog for Flutter

simple_loading_dialog

A simple full-screen loading dialog for Flutter.

Features

  • A very simple full-screen loading dialog.
  • Can block user input while waiting for a Future to complete.
  • Rethrows exceptions on error.
  • Customizable dialog appearance.
  • Returns the result of the Future.

Usage

To use this package, add simple_loading_dialog as a dependency in your pubspec.yaml file.

Showing the dialog

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.

Customizing the appearance

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'),
      ],
    ),
  ),
);

Handling errors

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.
}

License

This package is licensed under the MIT License. See the LICENSE file for details.

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:simple_loading_dialog/simple_loading_dialog.dart'; 

example/lib/main.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

#flutter #dialog 

A Simple Full-screen Loading Dialog for Flutter

Easiest Way to Show Alert Dialog in Flutter App

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.

Usage

Example

To use this package :

  • add the dependency to your pubspec.yaml file.
dependencies:

  emerge_alert_dialog: ^0.0.3

How to use

    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"),
             ),
          );
        },
      );
    }

Screenshot

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:emerge_alert_dialog/emerge_alert_dialog.dart'; 

example/lib/main.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

#alert #dialog 

Easiest Way to Show Alert Dialog in Flutter App

Customizable progress dialog for Flutter applications

dim_loading_dialog

Customizable progress dialog for Flutter applications with smooth animation for background dim color and blur.

Example

example gif

Getting Started

Install

Add dependency to pubspec.yaml file :
dim_loading_dialog: 0.0.1

Run this command :
$ flutter pub get

Import

Import class in your project :
import 'package:dim_loading_dialog/dim_loading_dialog.dart';

Showing Dialog

Show simple progress dialog :

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

Customize loading widget :

 DimLoadingDialog customdimDialog = DimLoadingDialog(
	 context,
	 blur: 2,
	 backgroundColor: Color(0x33000000),
	 loadingWidget: Container(
		 width: 150,
		 height: 150,
		 color: Colors.red,
		 child: CircularProgressIndicator(),    
    ));  

Properties

NameTypeDescriptionDefault
backgroundColorColorDialog dim(background) ColorColor (0x99000000)
blurdoubleBlur amount of dialog background0
dismissableboolSetting this true lets user dismiss dialog by touching outside of it.true
onDismissFunctionThis function triggers when user dismisses dialog.-
loadingWidgetWidgetDialog's widget. You can use your own widget when showing dialog.simple widget
useSafeAreaboolSetting 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
animationDurationDurationThis duration defines how much will take for blur and background color to appear.Duration (milliseconds : 300)

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:dim_loading_dialog/dim_loading_dialog.dart'; 

example/lib/main.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

#flutter #dialog 

Customizable progress dialog for Flutter applications

A Light Weight Package to Show Progress Dialog

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)

Supported Dart Versions

Dart SDK version >= 2.7.0

Demo

Normal dialog Demo Download dialog Demo

Installation

Add the Package

dependencies:
  progress_dialog: ^1.2.4

How to use

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

  1. Initialize the ProgressDialog object
     
final ProgressDialog pr = ProgressDialog(context);
  1. By default it is a normal dialog to show some message, if you would like to use it to show percentage of progress done, specify the optional type parameter and specify if you want your dialog to dismiss when back button is pressed isDismissible parameter (Optional)
     
//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);
  1. Style the progress dialog (Optional)
     
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
  1. Showing the progress dialog
     
await pr.show();
  1. Dynamically update the content shown out there
     
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
  1. Dismissing the progress dialog
     
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

Check if progress dialog is showing

bool isProgressDialogShowing = pr.isShowing();
print(isProgressDialogShowing);

Use custom body

    pr = ProgressDialog(
      context,
      type: ProgressDialogType.Normal,
      isDismissible: true,
      /// your body here
      customBody: LinearProgressIndicator(
        valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
        backgroundColor: Colors.white,
      ),
    );

Demo

Normal dialog Demo Download dialog Demo

Default configuration/styles

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.

AttributeValue
Dismissibletrue
ProgressDialogTypeProgressDialogType.Normal
BackgroundColorColors.white
BorderRadiusRoundedRectangularBorder(radius: 8.0)
AnimationCurveCurves.easeInOut
Elevation8.0
ProgressWidgetDouble_rings_loding_indicator
MessageTextStylecolor: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600
ProgressTextStylecolor: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400
showLogsfalse

Well let's discuss limits for configuring it

AttributeCan be updated during instantiatingCan be updated during stylingCan be updated during dialog is shown
DismissibleYesNoNo
ProgressDialogTypeYesNoNo
BackgroundColorNoYesNo
BorderRadiusNoYesNo
AnimationCurveNoYesNo
ElevationNoYesNo
ProgressWidgetNoYesYes
MessageTextStyleNoYesYes
ProgressTextStyleNoYesYes
ShowLogsYesNoNo

Want to contribute?

Pull requests and issues are always welcome!

How to contribute?

  1. Fork the repository
  2. Clone it to your local machine
  3. Open the project in your favourite editor
  4. Open cmd/terminal and run flutter clean and then flutter packages get
  5. Make the changes
  6. Create a Pull Request

View the issues here

This library is only tested for Android, iOS contributors are most welcome


Loading indicator -> https://loading.io/

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:progress_dialog_fork/progress_dialog_fork.dart'; 

example/lib/main.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

#dialog #flutter 

A Light Weight Package to Show Progress Dialog

Simple Popup Confirmation Dialog with Flutter

simple_confirm

简洁的确认探出窗

开始使用

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:simple_confirm/simple_confirm.dart'; 

example/lib/main.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

#flutter #dialog #popup 

Simple Popup Confirmation Dialog with Flutter

Slide Popup Dialog in Flutter

slide_popup_dialog_null_safety

Popup dialog with slide mechanism. Use it like AlertDialog or SimpleDialog.

Gif Example

How to use

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;
  1. Add this method to your State Widget.
void _showDialog() {
  slideDialog.showSlideDialog(
    context: context,
    child: Text("Hello World"),
  );
}

Code Example

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,
    );
  }
}

Gif Example

Use this package as a library

Depend on it

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.

Import it

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'; 

example/lib/main.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

#flutter #dialog 

Slide Popup Dialog in Flutter
Rupert  Beatty

Rupert Beatty

1668134460

Alerttoast: Create Apple-like Alerts & Toasts using SwiftUI

AlertToast-SwiftUI

Present Apple-like alert & toast in SwiftUI

🌄 Example

ToastExample.gif

🔭 Overview

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…

  • Built with pure SwiftUI.
  • 3 Display modes: 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).
  • Supports Light & Dark Mode.
  • Works with any kind of view builder.
  • Localization support.
  • Font & Background customization.

If you like the project, don't forget to put star 🌟.

💻 Installation

Cocoapods

AlertToast Cocapods Website

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'

Swift Package Manager

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


Manually

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.

🧳 Requirements

  • iOS 13.0+ | macOS 11+
  • Xcode 12.0+ | Swift 5+

🛠 Usage

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.

Usage example with regular alert

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!")
        }
    }
}

Complete Modifier Example

.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
})

Alert Toast Parameters

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?)

Available Alert Types:

  • Regular: text only (Title and Subtitle).
  • Complete: animated checkmark.
  • Error: animated xmark.
  • System Image: name image from SFSymbols.
  • Image: name image from Assets.
  • Loading: Activity Indicator (Spinner).

Alert dialog view modifier (with default settings):

.toast(isPresenting: Binding<Bool>, duration: Double = 2, tapToDismiss: true, alert: () -> AlertToast , onTap: () -> (), completion: () -> () )

Simple Text Alert:

AlertToast(type: .regular, title: Optional(String), subTitle: Optional(String))

Complete/Error Alert:

AlertToast(type: .complete(Color)/.error(Color), title: Optional(String), subTitle: Optional(String))

System Image Alert:

AlertToast(type: .systemImage(String, Color), title: Optional(String), subTitle: Optional(String))

Image Alert:

AlertToast(type: .image(String), title: Optional(String), subTitle: Optional(String))

Loading Alert:

//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.

📖 Article

I wrote an article that contains more usage examples.

Medium - How to toast an alert in SwiftUI

👨‍💻 Contributors

All issue reports, feature requests, pull requests and GitHub stars are welcomed and much appreciated.



Download Details:

Author: elai950
Source Code: https://github.com/elai950/AlertToast 
License: MIT license

#swift #apple #alert #xcode #dialog #popup 

Alerttoast: Create Apple-like Alerts & Toasts using SwiftUI
Rupert  Beatty

Rupert Beatty

1666763880

A Great & Customizable Alert That Can Substitute UIAlertController

PMAlertController

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!

Icon

Features


  •  Header View
  •  Header Image (Optional)
  •  Title
  •  Description message
  •  Customizations: fonts, colors, dimensions & more
  •  1, 2 buttons (horizontally) or 3+ buttons (vertically)
  •  Closure when a button is pressed
  •  Text Fields support
  •  Similar implementation to UIAlertController
  •  Cocoapods
  •  Carthage
  •  Animation with UIKit Dynamics
  •  Objective-C compatibility
  •  Swift 4, Swift 4.2 & Swift 5 support
  •  Swift Package Manager

Requirements


  • iOS 9.0+
  • Xcode 10+

CocoaPods


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


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.

Manually


  1. Download and drop /Library folder in your project.
  2. Congratulations!

Usage


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.

Show a simple alert with two buttons and one textfield

//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)

Swift compatibility

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

Third Party Bindings

React Native

You may now use this library with React Native via the module here

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgements

Made with ❤️ by Paolo Musolino.

Follow me on:

💼 Linkedin

🤖 Twitter

🌇 Instagram

👨🏼‍🎤 Facebook


Download Details:

Author: pmusolino
Source Code: https://github.com/pmusolino/PMAlertController 
License: MIT license

#swift #alert #modal #dialog 

A Great & Customizable Alert That Can Substitute UIAlertController

A New Flutter Plugin Project for Dialog

cf_dialog_required

A new flutter plugin project.

Getting Started

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.

Use this package as a library

Depend on it

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.

Import it

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

#flutter #dialog 

A New Flutter Plugin Project for Dialog

Bottom Dialog Is A Picker Dialog for Pick with Flutter

bottom_dialog

Bottom dialog is a picker dialog for pick with single or multiply chooses. with support of adding icons or and search.

 

Getting Started

Examples: BottomModelExample

 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)
    ];

Examples: ShowDialog

    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,
    );

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:bottom_dialog/bottom_dialog.dart'; 

example/lib/main.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

#flutter #picker #dialog 

Bottom Dialog Is A Picker Dialog for Pick with Flutter

GDPR Dialog for Flutter

GDPR dialog

"showDialog()" calling: gets native request to android/ios Consent Form dialog and sets result as boolean:

  • true = requested Consent Form loaded (but may not be shown);
  • false = error with Consent Form loading.

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:

  • in iOS form will be shown and the user can change their consent option;
  • in Android form will not be shown. To reset the choice user need to reinstall the app.

Usage

GdprDialog.instance.showDialog(isForTest: true, testDeviceId: 'xxxxxxxxxxxxxxx')
                      .then((onValue) {
                    print('result === $onValue');
                  });

In the release build, you only does not need a parameters.

Method getConsentStatus() that return consent status

Usage

GdprDialog.instance.getConsentStatus();

It will return string of consent status:

  • OBTAINED
  • REQUIRED
  • NOT_REQUIRED
  • UNKNOWN

Statuses explaining

API, which depends on Android v2 Embedding, can not show you the real status of personalized ad.

  • OBTAINED status means, that user already chose one of the variants ('Consent' or 'Do not consent');
  • REQUIRED status means, that form should be shown by user, because his location is at EEA or UK;
  • NOT_REQUIRED status means, that form would not be shown by user, because his location is not at EEA or UK;
  • UNKNOWN status means, that there is no information about user location.

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:gdpr_dialog/gdpr_dialog.dart'; 

example/lib/main.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

#flutter #android #dialog 

GDPR Dialog for Flutter

A Light Weight Package to Show Progress Dialog

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 :)

Demo

Normal dialog Demo Download dialog Demo

How to use

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

  1. Initialize the ProgressDialog object
     
final ProgressDialog pr = ProgressDialog(context);
  1. By default it is a normal dialog to show some message, if you would like to use it to show percentage of progress done, specify the optional type parameter and specify if you want your dialog to dismiss when back button is pressed isDismissible parameter (Optional)
     
//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);
  1. Style the progress dialog (Optional)
     
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
  1. Showing the progress dialog
     
await pr.show();
  1. Dynamically update the content shown out there
     
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
  1. Dismissing the progress dialog
     
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

Check if progress dialog is showing

bool isProgressDialogShowing = pr.isShowing();
print(isProgressDialogShowing);

Use custom body

    pr = ProgressDialog(
      context,
      type: ProgressDialogType.Normal,
      isDismissible: true,
      /// your body here
      customBody: LinearProgressIndicator(
        valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
        backgroundColor: Colors.white,
      ),
    );

Demo

Normal dialog Demo Download dialog Demo

Default configuration/styles

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.

AttributeValue
Dismissibletrue
ProgressDialogTypeProgressDialogType.Normal
BackgroundColorColors.white
BorderRadiusRoundedRectangularBorder(radius: 8.0)
AnimationCurveCurves.easeInOut
Elevation8.0
ProgressWidgetDouble_rings_loding_indicator
MessageTextStylecolor: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600
ProgressTextStylecolor: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400
showLogsfalse

Well let's discuss limits for configuring it

AttributeCan be updated during instantiatingCan be updated during stylingCan be updated during dialog is shown
DismissibleYesNoNo
ProgressDialogTypeYesNoNo
BackgroundColorNoYesNo
BorderRadiusNoYesNo
AnimationCurveNoYesNo
ElevationNoYesNo
ProgressWidgetNoYesYes
MessageTextStyleNoYesYes
ProgressTextStyleNoYesYes
ShowLogsYesNoNo

Loading indicator -> https://loading.io/

Use this package as a library

Depend on it

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.

Import it

Now in your Dart code, you can use:

import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart'; 

example/lib/main.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

#weight #dialog #flutter 

A Light Weight Package to Show Progress Dialog

A Flutter Project Which Contains Lots of Beautiful Alert Dialog

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.

Show some ❤️ and star the repo to support the project

DetailsScreenshotCode
Diffrent alert boxes  
Simple Alert BoxSimpleAlertBox(context: context);
Info Alert BoxInfoAlertBox(context: context);
Success Alert BoxSuccessAlertBox(context: context);
Warning Alert BoxWarningAlertBox(context: context);
Danger Alert BoxDangerAlertBox(context: context);
Dark Alert BoxDarkAlertBox(context: context);
Simple Alert Box CenterSimpleAlertBoxCenter(context: context);
Info Alert Box CenterInfoAlertBoxCenter(context: context);
Success Alert Box CenterSuccessAlertBoxCenter(context: context);
Warning Alert Box CenterWarningAlertBoxCenter(context: context);
Danger Alert Box CenterDangerAlertBoxCenter(context: context);
Dark Alert Box CenterDarkAlertBoxCenter(context: context);
Confirm BoxConfirmAlertBox(context: context);
Confirm Box DarkConfirmAlertBoxDark(context: context);
Delete Alert BoxDeleteAlertBox(context: context);
Success Backgroung Alert BoxSuccessBgAlertBox(context: context);
Info Backgroung Alert BoxInfoBgAlertBox(context: context);
Warning Backgroung Alert BoxWarningBgAlertBox(context: context);
Danger Backgroung Alert BoxDangerBgAlertBox(context: context);
Dark Backgroung Alert BoxDarkBgAlertBox(context: context);
Simple Backgroung Alert BoxSimpleBgAlertBox(context: context);
Custom Backgroung Alert BoxCustomBgAlertBox(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

Depend on it

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.

Import it

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

#flutter #Alert #dialog 

A Flutter Project Which Contains Lots of Beautiful Alert Dialog
Rocio  O'Keefe

Rocio O'Keefe

1661523060

Flutter Material Month Picker Dialog

mat_month_picker_dialog

Material month picker with layout inspired by this article.

Getting started

Add mat_month_picker_dialog to your pubspec.yaml

Usage

final selected = await showMonthPicker(
    context: context,
    initialDate: DateTime.now(),
    firstDate: DateTime(1970),
    lastDate: DateTime(2050)
);

Screenshots

Year selectorMonth selector

Use this package as a library

Depend on it

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.

Import it

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(),
    );
  }
}

Download Details:

Author: leoshusar
Source Code: https://github.com/leoshusar/mat_month_picker_dialog 
License: MIT license

#flutter #dart #dialog 

Flutter Material Month Picker Dialog
Rocio  O'Keefe

Rocio O'Keefe

1660770960

Overlay_dialog: A Flutter Package for Showing Platform Dialogs

OverlayDialog

A Flutter package for showing platform dialogs without using new routes.

  • No confusing navigation - dialog added to the current route
  • Supports Material and Cupertino dialogs
  • Flutter-based solution, no additional imports needed

![Overlay Dialog Demo](https://github.com/mera-company/flutter-overlay-dialog/blob/master/doc/overlay_dialog_demo.gif?raw=true =300x533)

What's the problem?

During project develop we stucks with several problems with Flutter dialogs. This package solves several problems of standart Flutter approach.

  • Flutter creates a new route when adding dialogs with 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.
  • Dialog shares the same navigator with app pages and can't be named. 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

  • OverlayDialog uses Flutter dialogs under the cover, so widgets UI is the same. Material and Cupertino alert and progress dialogs are available. Dialog style is set via App theme.
  • OverlayDialog adds dialog to the route overlay without new route creating. This makes lifecycle and navigation calls clearly.
  • OverlayDialog follows design guidelines and handles back press for android devices (this may be disabled if needed). It animates dialog appear and disappear to follow native design.
  • DialogHelper consolidates all logic for show / hide actions. Previously opened dialogs closes automatically when new dialog added.

Usage

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 Theme

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
  )
)

Use this package as a library

Depend on it

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.

Import it

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;
    });
  }
}

Development

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.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Contributors/People

Anastasia Artemyeva (anastasia.artemyeva@orioninc.com)

Todos

  • Add input dialogs
  • Add custom animation
  • Add tests

Download Details:

Author: Mera-company
Source Code: https://github.com/mera-company/flutter-overlay-dialog 
License: View license

#flutter #dart #dialog 

Overlay_dialog: A Flutter Package for Showing Platform Dialogs