flutter_dropdown_alert 1.0.2
flutter_dropdown_alert: ^1.0.2 copied to clipboard

A dropdown alert package for flutter, help user notify the alert like push notification when call api success, fail or waring.

pub package

flutter_dropdown_alert #

A dropdown alert package for flutter

Dropdown alert will help to notify to user when you call api success, error or something like that. It's will similar with push notification but you can custom more than that. You can show alert at anywhere without widget.

Demo #

Top: #

Bottom: #

How to use it. #

# pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  flutter_dropdown_alert: <last-version>

Just create a Stack widget and add DropdownAlert() inside MaterialApp which should be in main.dart like this:

import 'package:flutter_dropdown_alert/dropdown_alert.dart';
 MaterialApp(
       title: 'Dropdown Alert Demo',
       theme: ThemeData(
         visualDensity: VisualDensity.adaptivePlatformDensity,
       ),
       builder: (context, child) => Stack(
         children: [
            child!,
            DropdownAlert()
         ],
       ),
       home: MyHomePage(title: 'Flutter Dropdown Alert Demo'),
     );

Full example source code: #

https://github.com/vantuan88291/flutter_bloc_modular

Show alert anywhere, even inside bloc without widget: #

Next, import 'alert_controller.dart' into your dart code

import 'package:flutter_dropdown_alert/alert_controller.dart';
   AlertController.show("Title", "message here!", TypeAlert.success, payload);

The payload param is Map<String, dynamic>, this param is optional, should use to give data into the alert and get it when click on alert.

Hide alert: #

The alert will automatically hide, but if you use delayDismiss: 0, it will freeze and not auto hide, you have to hide the alert by this code:

   AlertController.hide();

Listener when click on alert: #

There are 2 ways to do that:

  • Using listener of controller, put this code inside initState() of widget:
   AlertController.onTabListener((Map<String, dynamic>? payload, TypeAlert type) {
         print("$payload - $type");
       });
  • Using param onTap:
   DropdownAlert(onTap: (Map<String, dynamic> payload?, TypeAlert type) {
                print("$payload - $type");
             },)

TypeAlert #

Typedescription
TypeAlert.successType when action success, the background of alert will green
TypeAlert.warningType when action warning, the background of alert will brown
TypeAlert.errorType when action error, the background of alert will red

parameters #

parameterdescriptiondefault
onTapCallback when tab to alert, will give: Function(Map<String, dynamic>, TypeAlert)null
successImageImage.asset() of success alert, uri of assets imageIcon widget
warningImageImage.asset() of warning alert, uri of assets imageIcon widget
errorImageImage.asset() of error alert, uri of assets imageIcon widget
errorBackgroundColor of background when errorColors.red
successBackgroundColors.green
warningBackground0xFFCE863D
titleStyleTextStyle of title
contentStyleTextStyle of content
maxLinesTitlenull
maxLinesContentnull
durationduration of animation300
delayDismissdelay time when alert auto dismiss, set to 0 if you want to freeze alert3000
positionshow the position of alert, include: AlertPosition.TOP, AlertPosition.BOTTOMAlertPosition.TOP

The ideal from react-native-dropdownalert

30
likes
120
pub points
81%
popularity

A dropdown alert package for flutter, help user notify the alert like push notification when call api success, fail or waring.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_dropdown_alert