• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Dart
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple modal progress HUD (heads-up display, or progress indicator) for flutter

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!

More Repositories

1

screenshots

Screenshots: A command line utility and package for capturing screenshots for Flutter
Dart
263
star
2

fledge

Fledge: A CI/CD tool for Flutter
Dart
160
star
3

sylph

Runs Flutter integration tests on real devices in cloud.
Dart
157
star
4

flutter_app

Flutter counter app demonstrating unit, widget and end-to-end integration testing with code coverage
Dart
23
star
5

test_emulators

Test start-up of android emulators on Travis and Cirrus. Plus run a test.
Dart
14
star
6

todo

Demo app for fledge
Dart
13
star
7

flown

Clone a flutter app from a url.
Dart
8
star
8

go

Go Examples
Makefile
7
star
9

tool_base

Flutter tools' base
Dart
4
star
10

hot-emulator

Docker image of android emulator with quickboot snapshot
Shell
3
star
11

fake_process_manager

A fake process manager for testing
Dart
2
star
12

flutter_ios_build

Test creating build conditions on macOS for iOS .app and .ipa for testing on real devices
Shell
2
star
13

test_internationalization

Demo of flutter driver issue https://github.com/flutter/flutter/issues/27785
Dart
2
star
14

default_flutter_app

The default flutter app with separate testable flutter app running on Travis and Cirrus
Dart
2
star
15

chingle

Video chat iPhone app based on XMPP and Jingle
2
star
16

tool_base_test

Flutter tools' base test support
Dart
2
star
17

test_flutter_saucelabs

Flutter instrumentation/integration testing via Sauce Labs
Dart
2
star
18

giterdone

Demo of CI/CD for Flutter
Dart
1
star
19

google_maps_flutter_jitter

Shows jitter when route is animated on Android
Dart
1
star
20

plugins

Dart
1
star
21

scala-principles

Functional Programming Principles in Scala -- Coursera
Scala
1
star
22

tool_mobile

Flutter tools' base plus mobile
Dart
1
star
23

grpc_series_flutter

Source code for a series of articles describing experience developing a production grade backend for integrating Flutter with MongoDB's geospatial features.
Java
1
star
24

fledge_demo_app

Demo app for fledge https://github.com/mmcc007/fledge
HTML
1
star
25

flutter_architecture_samples_temp_old

Dart
1
star
26

flutter_architecture_samples_temp

Dart
1
star
27

flutter_gallery

Dart
1
star
28

reporting

Report analytics to Google Analytics and crashes to a crash server for Dart command line apps
Dart
1
star
29

wiremock-example

Example of using WireMock with RestAssured.
Java
1
star