패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.1.3

modal_progress_hud

모달 진행률 표시 위젯 (HUD = 헤드업 디스플레이). 비동기 호출 중에 위젯에 대한 액세스를 차단하기 위해 다른 위젯을 감쌉니다. 사용자 지정 스피너도 수락합니다.

30일 다운로드
1.1천
좋아요
485
Pub 점수
40

패키지 설치

flutter pub add modal_progress_hud

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

어떤 위젯 위에 로딩 오버레이를 표시하기 위한 모달 진행률 표시기(HUD)를 제공하는 플러터 패키지입니다. API 호출이나 데이터 처리와 같은 비동기 작업 중 사용자 상호작용을 차단하여 원활한 UX를 보장합니다. 사용자가 자신만의 로딩 애니메이션을 사용할 수 있도록 사용자 정의 가능한 스피너를 지원합니다. 결과를 기다리는 동안 실수로 탭하는 것을 방지하는 데 이상적입니다. 버튼이나 폼과 같은 위젯과도 원활하게 작동합니다.

사용 사례

  • 비동기 작업 중에 UI 차단
  • 폼에서 로딩 상태 표시
  • 데이터 가져오기 중 탭 방지
  • 시각적 피드백을 통한 사용자 경험 향상
  • 로딩 인디케이터 사용자 정의

주요 기능

  • 모달 오버레이가 상호작용을 차단합니다
  • 사용자 정의 스피너 지원
  • 기존 위젯과의 간단한 통합
  • 비침입적 로딩 표시
  • 모든 위젯 트리와 호환됩니다

적합한 대상

  • 빠른 로딩 오버레이가 필요한 개발자
  • 자주 비동기 작업을 수행하는 앱
  • 명확한 로딩 상태가 필요한 UI
  • UX 일관성을 우선시하는 팀
  • 최소한의 보일러플레이트를 사용하는 프로젝트

고려 사항

  • 오류 상태를 처리하지 않습니다
  • 내장된 재시도 메커니즘이 없음
  • 스피너 사용자 지정에는 추가 설정이 필요합니다
  • 기본 이상의 스타일링 옵션이 제한되어 있음
  • 복잡한 로딩 워크플로우에 적합하지 않습니다

원본 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!

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트