easy_alert 0.0.2

pub package

easy_alert #

A package for flutter to use alert and toast within one line code.

Getting Started #

Add

    easy_alert:

to your pubspec.yaml, and run flutter packages get in your project root directory.

Showcases #

ROADMAP #

  • [x] alert
  • [x] confirm
  • [x] toast
  • [ ] customize alert dialog
  • [ ] customize toast
  • [ ] support bottom sheet.
  • [ ] support input

Integrate with your flutter app #

void main() => runApp(new AlertProvider(
      child: new YourApp(),
      config: new AlertConfig(
        ok: "OK text for `ok` button in AlertDialog", 
        cancel: "CANCEL text for `cancel` button in AlertDialog"),
    ));

alert #

  Alert.alert(context, title: "Hello", content: "this is a alert")
      .then((_) => Alert.toast(context, "You just click ok"));

confirm #

 Alert.confirm(context, title: "Hello", content: "this is a alert")
          .then((int ret) =>
              Alert.toast(context, ret == Alert.OK ? "ok" : "cancel"));

toast #

Alert.toast(context,"Very long toast",position: ToastPosition.bottom, duration: ToastDuration.long);

[0.0.1]

* support basic usage: alert ,confirm, toast

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:easy_alert/easy_alert.dart';

void main() => runApp(new AlertProvider(
      child: new MyApp(),
      config: new AlertConfig(ok: "OK", cancel: "CANCEL"),
    ));

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Easy alert example',
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("Easy alert example"),
      ),
      body: new Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          new RaisedButton(
            onPressed: () {
              Alert.alert(context, title: "Hello")
                  .then((_) => Alert.toast(context, "You just click ok"));
            },
            child: new Text("alert"),
          ),
          new RaisedButton(
            onPressed: () {
              Alert.alert(context, title: "Hello", content: "this is a alert")
                  .then((_) => Alert.toast(context, "You just click ok"));
            },
            child: new Text("alert with content"),
          ),
          new RaisedButton(
            onPressed: () {
              Alert.confirm(context, title: "Hello", content: "this is a alert")
                  .then((int ret) =>
                      Alert.toast(context, ret == Alert.OK ? "ok" : "cancel"));
            },
            child: new Text("confirm"),
          ),
          new RaisedButton(
            onPressed: () {
              Alert.toast(context, "center toast",
                  position: ToastPosition.center);
            },
            child: new Text("show center toast"),
          ),
          new RaisedButton(
            onPressed: () {
              Alert.toast(context, "top toast", position: ToastPosition.top);
            },
            child: new Text("show top toast"),
          ),
          new RaisedButton(
            onPressed: () {
              Alert.toast(context,
                  "bottom long toast bottom long toastbottom long toastbottom long toastbottom long toastbottom long toastbottom long toast",
                  position: ToastPosition.bottom, duration: ToastDuration.long);
            },
            child: new Text("show bottom long toast"),
          ),
        ],
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  easy_alert: ^0.0.2

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:easy_alert/easy_alert.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
87
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Sep 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/src/provider.dart. (-5.48 points)

Analysis of lib/src/provider.dart reported 1 warning, 1 hint:

line 111 col 5: Parameters can't override default values, this method overrides 'ToastManager.showToast' where 'duration' has a different value.

line 148 col 8: The declaration '_next' isn't referenced.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is getting outdated. (-3.01 points)

The package was last published 53 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.40.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test