flutter_alert 0.4.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 77

flutter_alert

Build Status

Flutter package which shows a crossplatform alert messages on Android (Material) and iOS (Cupertino).

Getting Started

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

dependencies:
  flutter_alert: ^0.4.0

You can install packages from the command line:

$ flutter packages get

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

Example

In your Dart code, add this import:

import 'package:flutter_alert/flutter_alert.dart';

And later show an alert when neccessary:

  void _showMessageDialog() {
    showAlert(
      context: context,
      title: "Awesome feature enabled.",
    );
  }

  void _showQuestionDialog() {
    showAlert(
      context: context,
      title: "Delete file?",
      body: "Should we delete the file XYZ?",
      actions: [
        AlertAction(
          text: "Delete",
          isDestructiveAction: true,
          onPressed: () {
            // TODO
          },
        ),
      ],
      cancelable: true,
    );
  }

Contributors

Thanks goes to these people (emoji key):

<img src="https://avatars.githubusercontent.com/u/139310?s=100&v=4" width="100px;"/><br /><sub><b>Christoph Jerolimov</b></sub><br />💻 📖 ⚠️<img src="https://avatars1.githubusercontent.com/u/7152774?s=100&v=4" width="100px;"/><br /><sub><b>Christian Stahl</b></sub><br />💻 🤔<img src="https://avatars1.githubusercontent.com/u/1096485?s=100&v=4" width="100px;"/><br /><sub><b>Pascal Welsch</b></sub><br />🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

[0.4.0]

  • Breaking change: Remove attribute useCupertino in showAlert method. It no uses now just Platform.isIOS to decide if it renders a Cupertino or Material UI alert dialog. But this library provides now two new separate methods to force a platform specific alert dialog:

    • showCupertinoAlert
    • showMaterialAlert

[0.3.0]

  • Structure changes to fix unit tests / CI.

[0.2.0]

  • Add documentation for all public fields.
  • Fix an issue that barrierDismissable should be never null.
  • Use showCupertinoDialog to improve the UI (background/shadow) of the alert dialog on iOS.

[0.1.0]

  • Initial release

example/flutter_alert.dart

import 'package:flutter/material.dart';

import 'package:flutter_alert/flutter_alert.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHome(),
    );
  }
}

class MyHome extends StatelessWidget {
  void _showDialog(BuildContext context) {
    showAlert(
      context: context,
      title: "Delete file?",
      body: "Should we delete the file XYZ?",
      actions: [
        AlertAction(
          text: "Delete",
          isDestructiveAction: true,
          onPressed: () {
            // TODO
          },
        ),
      ],
      cancelable: true,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("OK"),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => _showDialog(context),
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_alert: ^0.4.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_alert/flutter_alert.dart';
  
Version Uploaded Documentation Archive
0.4.0 Jan 8, 2019 Go to the documentation of flutter_alert 0.4.0 Download flutter_alert 0.4.0 archive
0.3.0 Dec 16, 2018 Go to the documentation of flutter_alert 0.3.0 Download flutter_alert 0.3.0 archive
0.2.0 Dec 16, 2018 Go to the documentation of flutter_alert 0.2.0 Download flutter_alert 0.2.0 archive
0.1.0 Dec 16, 2018 Go to the documentation of flutter_alert 0.1.0 Download flutter_alert 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
54
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]
77
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

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