パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.1.3

modal_progress_hud

モーダルプログレスインジケーターウィジェット(HUD = ヘッドアップディスプレイ)。非同期呼び出し中にウィジェットへのアクセスをブロックするため、別のウィジェットをラップします。カスタムスピンナーも受け入れます。

30日間ダウンロード
1110
いいね数
485
Pub ポイント
40

パッケージをインストール

flutter pub add modal_progress_hud

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

任意のウィジェットの上にロードオーバーレイを表示するためのモーダルプログレスインジケーター(HUD)を提供するFlutterパッケージです。API呼び出しやデータ処理などの非同期操作中にユーザーの操作をブロックし、スムーズなUXを確保します。カスタマイズ可能なスピナーをサポートしており、開発者は独自のロードアニメーションを使用できます。結果待ち中の誤タップを防ぐのに最適です。ボタンやフォームなどのウィジェットともシームレスに動作します。

用途

  • 非同期操作中にUIをブロックする
  • フォーム内の読み込み状態を表示する
  • データ取得中にタップを防ぐ
  • 視覚フィードバックによるUXの向上
  • ロードインジケーターのカスタマイズ

主な機能

  • モーダルオーバーレイが操作をブロックする
  • カスタムスピンナーをサポート
  • 既存のウィジェットとの簡単な統合
  • 侵襲的でないロード表示
  • 任意の Widget ツリーと連携可能

適している対象

  • 迅速なロードオーバーレイが必要な開発者
  • 頻繁な非同期操作を持つアプリ
  • 明確な読み込み状態を必要とする UI
  • UXの一貫性を重視するチーム
  • 最小限のボイラープレートを使用するプロジェクト

注意事項

  • エラー状態を処理しません
  • 組み込みの再試行メカニズムなし
  • Spinner のカスタマイズには追加の設定が必要です
  • 基本的なもの以外のスタイリングオプションが限られている
  • 複雑な読み込みワークフローには適していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

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!

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト