flutter_alert 0.4.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

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):


Christoph Jerolimov
💻 📖 ⚠️

Christian Stahl

💻 🤔

Pascal Welsch

🤔

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 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:flutter_alert/flutter_alert.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
88
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]
94
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_alert_cupertino.dart.

Run flutter format to format lib/flutter_alert_cupertino.dart.

Format lib/flutter_alert_material.dart.

Run flutter format to format lib/flutter_alert_material.dart.

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 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