modal_progress_hud 0.1.3

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

modal_progress_hud #

A simple widget wrapper to enable modal progress HUD (a modal progress indicator, HUD = Heads Up Display)

pub package Build Status Coverage Status

Inspired by this article.

Demo #

Demo

See example for details

Usage #

Add the package to your pubspec.yml file.

dependencies:
  modal_progress_hud: ^0.1.3

Next, import the library into your widget.

import 'package:modal_progress_hud/modal_progress_hud.dart';

Now, all you have to do is simply wrap your widget as a child of ModalProgressHUD, typically a form, together with a boolean that is maintained in local state.

...
bool _saving = false
...

@override
Widget build(BuildContext context) {
  return Scaffold(
     body: ModalProgressHUD(child: Container(
       Form(...)
     ), inAsyncCall: _saving),
  );
}

Options #

The current parameters are customizable in the constructor

ModalProgressHUD(
  @required inAsyncCall: bool,
  @required child: Widget,
  opacity: double,
  color: Color,
  progressIndicator: CircularProgressIndicator,
  offset: double
  dismissible: bool,
);

Example #

Here is an example app that demonstrates the usage.

  1. On initial load, _saving is false which causes your child widget to display
  2. When the form is submitted, _saving is set to true, which will display the modal
  3. Once the async call is complete, _saving is set back to false, hiding the modal
class SettingsPage extends StatefulWidget {
  @override
  _SettingsPageState createState() => new _SettingsPageState();
}

class _SettingsPageState extends State<SettingsPage> {
  bool _saving = false;

  void _submit() {

    setState(() {
      _saving = true;
    });

    //Simulate a service call
    print('submitting to backend...');
    new Future.delayed(new Duration(seconds: 4), () {
      setState(() {
        _saving = false;
      });
    });
  }

  Widget _buildWidget() {
    return new Form(
      child: new Column(
        children: [
          new SwitchListTile(
            title: const Text('Bedroom'),
            value: _bedroom,
            onChanged: (bool value) {
              setState(() {
                _bedroom = value;
              });
            },
            secondary: const Icon(Icons.hotel),
          ),
          new RaisedButton(
            onPressed: _submit,
            child: new Text('Save'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Flutter Progress Indicator Demo'),
        backgroundColor: Colors.blue,
      ),
      body: ModalProgressHUD(child: _buildWidget(), inAsyncCall: _saving),
    );
  }
}

Update: See this article on Medium about async form validation

See the example application source for a complete sample app using the modal progress HUD. Included in the example is a method for using a form's validators while making async calls (see flutter/issues/9688 for details).

Issues and feedback #

Please file issues to send feedback or report a bug. Thank you!

[0.1.3]

  • Performance optimization
  • Improved docs

[0.1.2]

  • Added option to dismiss modal
  • Refactored example

[0.1.1]

  • Added option to position progress indicator
  • Refactored example

[0.1.0]

  • Added support for Dart 2.0

[0.0.6]

  • Pass any progress indicator
  • Added tests and code coverage
  • Refactoring for tests

[0.0.5]

  • Changed layout of README and corrected spelling

[0.0.4]

  • Updated README

[0.0.3]

  • Fixed location of demo gif file

[0.0.2]

  • Added example of use of modal progress hud with login screen, form and async calls.

[0.0.1] - July 10, 2018

  • Simple countainer widget to enable modal progress hud (progress indicator)

example/README.md

example #

Update: see this article on Medium about async form validation

Sample app showing how to use modal_progress_hud in a login screen that makes calls to a backend. Also shows method to manage form verification with async calls (see flutter/issues/9688 for details).

Demo #

Demo

Use this package as a library

1. Depend on it

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


dependencies:
  modal_progress_hud: ^0.1.3

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:modal_progress_hud/modal_progress_hud.dart';
  
Version Uploaded Documentation Archive
0.1.3 Mar 19, 2019 Go to the documentation of modal_progress_hud 0.1.3 Download modal_progress_hud 0.1.3 archive
0.1.2 Oct 21, 2018 Go to the documentation of modal_progress_hud 0.1.2 Download modal_progress_hud 0.1.2 archive
0.1.1 Sep 18, 2018 Go to the documentation of modal_progress_hud 0.1.1 Download modal_progress_hud 0.1.1 archive
0.1.0 Aug 13, 2018 Go to the documentation of modal_progress_hud 0.1.0 Download modal_progress_hud 0.1.0 archive
0.0.6 Jul 14, 2018 Go to the documentation of modal_progress_hud 0.0.6 Download modal_progress_hud 0.0.6 archive
0.0.5 Jul 12, 2018 Go to the documentation of modal_progress_hud 0.0.5 Download modal_progress_hud 0.0.5 archive
0.0.4 Jul 11, 2018 Go to the documentation of modal_progress_hud 0.0.4 Download modal_progress_hud 0.0.4 archive
0.0.3 Jul 11, 2018 Go to the documentation of modal_progress_hud 0.0.3 Download modal_progress_hud 0.0.3 archive
0.0.2 Jul 11, 2018 Go to the documentation of modal_progress_hud 0.0.2 Download modal_progress_hud 0.0.2 archive
0.0.1 Jul 11, 2018 Go to the documentation of modal_progress_hud 0.0.1 Download modal_progress_hud 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
97
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
98
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <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