cool_alert 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new80

cool_alert #

A Flutter package to display animated alert dialogs

Usage #

To use this package, add cool_alert as a dependency in your pubspec.yaml file. And add this import to your file.

import 'package:cool_alert/cool_alert.dart';

Image #

Screenshot  Gif

Example #

CoolAlert.show(
   context: context,
   type: CoolAlertType.success,
   text: "Your transaction was successful!",
);

CoolAlert Class #

AttributeData typeDescriptionDefault Value
contextBuildContext@requiredNull
typeCoolAlertType@required - Type of alert dialog, ex: CoolAlertType.success for success dialogsNull
titleStringSet a custom title for dialogBased on the CoolAlertType selected
textStringSet the description text of the dialog.Null
confirmBtnTextStringText of confirm button'Ok'
confirmBtnTapFunctionFunction that handle click of confirm button() => Navigator.pop(context)
confirmBtnColorColorColor of confirm ButtonTheme.of(context).primaryColor
cancelBtnTextStringText of cancel button'Cancel'
cancelBtnTapFunctionFunction that handle click of cancel button() => Navigator.pop(context)
barrierDismissibleboolDissmiss dialog on touch overlaytrue
animTypeCoolAlertAnimTypeType of dialogue enter animationCoolAlertAnimType.scale

[1.0.1] - 24/06/2020 #

  • Updated documentation

[1.0.0] - 24/06/2020 #

  • Updated documentation

[0.0.2] - 21/06/2020 #

  • Updated README

[0.0.1] - 21/06/2020 #

  • Initial release

example/lib/main.dart

import 'package:cool_alert/cool_alert.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Cool Alert',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Cool Alert'),
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    final successAlert = _buildButton(
      onTap: () {
        CoolAlert.show(
          context: context,
          type: CoolAlertType.success,
          text: "Transaction completed successfully!",
        );
      },
      text: "Success",
      color: Colors.green,
    );

    final errorAlert = _buildButton(
      onTap: () {
        CoolAlert.show(
          context: context,
          type: CoolAlertType.error,
          title: "Oops...",
          text: "Sorry, something went wrong",
        );
      },
      text: "Error",
      color: Colors.red,
    );

    final warningAlert = _buildButton(
      onTap: () {
        CoolAlert.show(
          context: context,
          type: CoolAlertType.warning,
          text: "You just broke protocol",
        );
      },
      text: "Warning",
      color: Colors.orange,
    );

    final infoAlert = _buildButton(
      onTap: () {
        CoolAlert.show(
          context: context,
          type: CoolAlertType.info,
          text: "Buy two, get one free",
        );
      },
      text: "Info",
      color: Colors.blue[100],
    );

    final confirmAlert = _buildButton(
      onTap: () {
        CoolAlert.show(
          context: context,
          type: CoolAlertType.confirm,
          text: "Do you want to logout",
          confirmBtnText: "Yes",
          cancelBtnText: "No",
          confirmBtnColor: Colors.green
        );
      },
      text: "Confirm",
      color: Colors.lightGreen,
    );

    final loadingAlert = _buildButton(
      onTap: () {
        CoolAlert.show(
          context: context,
          type: CoolAlertType.loading,
        );
      },
      text: "Loading",
      color: Colors.grey,
    );

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(20.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            successAlert,
            errorAlert,
            warningAlert,
            infoAlert,
            confirmAlert,
            loadingAlert,
          ],
        ),
      ),
    );
  }

  Widget _buildButton({VoidCallback onTap, String text, Color color}) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 10.0),
      child: MaterialButton(
        color: color,
        minWidth: double.infinity,
        shape:
            RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
        onPressed: onTap,
        child: Padding(
          padding: const EdgeInsets.symmetric(vertical: 15.0),
          child: Text(
            text,
            style: TextStyle(
              color: Colors.white,
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cool_alert: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cool_alert/cool_alert.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
60
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • cool_alert that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flare_flutter ^2.0.3 2.0.5
flutter 0.0.0
vector_math ^2.0.8 2.0.8 2.1.0-nullsafety
Transitive dependencies
collection 1.14.12 1.14.13
flare_dart 2.3.4
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
Dev dependencies
flutter_test