Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter dropdown alert

flutter dropdown alert help to notify to user when success, warning or error like push notification.

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:

flutter_dropdown_alertz

bottom:

flutter_dropdown_alert

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,
       ),
       home: stack(
         children: [
           myhomepage(title: 'flutter dropdown alert demo'),
           dropdownalert()
         ],
       ),
     );

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

type description
typealert.success type when action success, the background of alert will green
typealert.warning type when action warning, the background of alert will brown
typealert.error type when action error, the background of alert will red

parameters

parameter description default
ontap callback when tab to alert, will give: function(map<string, dynamic>, typealert) null
successimage image.asset() of success alert, uri of assets image icon widget
warningimage image.asset() of warning alert, uri of assets image icon widget
errorimage image.asset() of error alert, uri of assets image icon widget
errorbackground color of background when error colors.red
successbackground colors.green
warningbackground 0xffce863d
titlestyle textstyle of title
contentstyle textstyle of content
maxlinestitle null
maxlinescontent null
duration duration of animation 300
delaydismiss delay time when alert auto dismiss, set to 0 if you want to freeze alert 3000
position show the position of alert, include: alertposition.top, alertposition.bottom alertposition.top

the ideal from react-native-dropdownalert


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.