Skip to content

Paul-Todd/sweetalert

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pub package

sweetalert

sweetalert for flutter.

Showcases

Getting started

Add dependency

sweetalert: any

Usage

Basic usage

 SweetAlert.show(context, title: "Just show a message");

With a subtitle

 SweetAlert.show(context,
                      title: "Just show a message",
                      subtitle: "Sweet alert is pretty");

With a success state

 SweetAlert.show(context,
                      title: "Just show a message",
                      subtitle: "Sweet alert is pretty",
                      style: SweetAlertStyle.success);

With a confirm state

SweetAlert.show(context,
                      title: "Just show a message",
                      subtitle: "Sweet alert is pretty",
                      style: SweetAlertStyle.confirm,
                      showCancelButton: true, onPress: (bool isConfirm) {
        if (isConfirm) {
          SweetAlert.show(context,style: SweetAlertStyle.success,title: "Success");
          // return false to keep dialog
          return false;
        }
      });

Do some job

 SweetAlert.show(context,
          subtitle: "Do you want to delete this message",
          style: SweetAlertStyle.confirm,
          showCancelButton: true, onPress: (bool isConfirm) {
        if(isConfirm){
          SweetAlert.show(context,subtitle: "Deleting...", style: SweetAlertStyle.loading);
          new Future.delayed(new Duration(seconds: 2),(){
            SweetAlert.show(context,subtitle: "Success!", style: SweetAlertStyle.success);
          });
        }else{
          SweetAlert.show(context,subtitle: "Canceled!", style: SweetAlertStyle.error);
        }
        // return false to keep dialog
        return false;
      });

With Widgets for Buttons

    SweetAlert.show(context,
      subtitle: "Do you want to delete this message",
      style: SweetAlertStyle.confirm,
      confirmButton: new RaisedButton(
        onPressed: () {
          SweetAlert.show(context,subtitle: "Success!", style: SweetAlertStyle.success);
        },
        color: Colors.purple,
        textColor: Colors.white,
        child: new Text("Confirm"),
      ),
      cancelButton: new RaisedButton(
        onPressed: () {
          SweetAlert.show(context, subtitle: "Cancelled!", style: SweetAlertStyle.error);
        },
        color: Theme.of(context).errorColor,
        child: new Text("Cancel"),
      ),
    );

About

sweetalert for flutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 96.6%
  • Objective-C 2.3%
  • Java 1.1%