easy_dialogs 1.0.0

easy_dialogs #

Easy to use dialogs with lists

  • SingleChoiceDialog
  • SingleChoiceConfirmationDialog
SingleChoiceConfirmationDialog 1SingleChoiceConfirmationDialog 2SingleChoiceDialog

SingleChoiceConfirmationDialog 1

SingleChoiceConfirmationDialog<String>(
            title: Text('Phone ringtone'),
            initialValue: _ringTone,
            items: _ringTones,
            onSelected: _onSelected,
            onSubmitted: _onSubmitted)

SingleChoiceConfirmationDialog 2

SingleChoiceConfirmationDialog<Color>(
            title: Text('Color'),
            initialValue: _color,
            items: _colors,
            contentPadding: EdgeInsets.symmetric(vertical: 16.0),
            divider: Container(
              height: 1.0,
              color: Colors.blue,
            ),
            onSubmitted: (Color color) {
              setState(() => _color = color);
            },
            itemBuilder: (Color color) =>
                Container(height: 100.0, color: color))

SingleChoiceDialog

SingleChoiceDialog<Color>(
              isDividerEnabled: true,
              title: Text('Pick a color'),
              items: _colors,
              onSelected: (Color color) {
                setState(() => _color = color);
              },
              itemBuilder: (Color color) =>
                  Container(height: 100.0, color: color))

[1.0.0] - 9/9/2018

  • Initial Release 🎉
  • It includes [SingleChoiceDialog] and [SingleChoiceConfirmationDialog]

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Easy Dialogs Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      routes: {
        '/': (context) => HomePage(),
      },
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  HomePageState createState() {
    return new HomePageState();
  }
}

class HomePageState extends State<HomePage> {
  final List<String> _ringTones = [
    'None',
    'Callisto',
    'Ganymede',
    'Luna',
    'Oberon',
    'Phobos',
    'Dione',
    'Jungle Gym',
    'Ukulele',
    'Snowflakes',
  ];

  final List<Color> _colors = [
    Colors.orange,
    Colors.pinkAccent,
    Colors.black,
    Colors.blue,
    Colors.brown,
    Colors.green,
  ];

  String _ringTone = "None";

  Color _color = Colors.black;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Settings'),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            onTap: _openRingtoneDialog,
            title: Text('Ringtone'),
            subtitle: Text(_ringTone),
            leading: Icon(Icons.music_note),
          ),
          ListTile(
              onTap: _openColorDialog,
              title: Text('Color'),
              subtitle: Container(
                margin: EdgeInsets.only(top: 8.0),
                height: 20.0,
                color: _color,
              ),
              leading: Icon(Icons.colorize)),
          ListTile(
              onTap: _openColorDialogWithoutConfirmation,
              title: Text('Color without confirmation'),
              subtitle: Container(
                margin: EdgeInsets.only(top: 8.0),
                height: 20.0,
                color: _color,
              ),
              leading: Icon(Icons.colorize)),
        ],
      ),
    );
  }

  _openRingtoneDialog() {
    showDialog(
        context: context,
        builder: (context) => SingleChoiceConfirmationDialog<String>(
            title: Text('Phone ringtone'),
            initialValue: _ringTone,
            items: _ringTones,
            onSelected: _onSelected,
            onSubmitted: _onSubmitted));
  }

  _openColorDialog() {
    showDialog(
      context: context,
      builder: (context) => SingleChoiceConfirmationDialog<Color>(
            title: Text('Color'),
            initialValue: _color,
            items: _colors,
            contentPadding: EdgeInsets.symmetric(vertical: 16.0),
            divider: Container(
              height: 1.0,
              color: Colors.blue,
            ),
            onSubmitted: (Color color) {
              setState(() => _color = color);
            },
            itemBuilder: (Color color) =>
                Container(height: 100.0, color: color),
          ),
    );
  }

  _openColorDialogWithoutConfirmation() {
    showDialog(
        context: context,
        builder: (context) => SingleChoiceDialog<Color>(
              isDividerEnabled: true,
              title: Text('Pick a color'),
              items: _colors,
              onSelected: (Color color) {
                setState(() => _color = color);
              },
              itemBuilder: (Color color) =>
                  Container(height: 100.0, color: color),
            ));
  }

  void _onSelected(String value) {
    print('Selected $value');
    setState(() {
      _ringTone = value;
    });
  }

  void _onSubmitted(String value) {
    print('Submitted $value');
    setState(() {
      _ringTone = value;
    });
  }
}

Use this package as a library

1. Depend on it

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


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

We analyzed this package on Sep 13, 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 suggestions

Format lib/single_choice_confirmation_dialog.dart.

Run flutter format to format lib/single_choice_confirmation_dialog.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-1.10 points)

The package was last published 52 weeks ago.

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