搜尋套件、儲存庫與 APP 分類

loading_overlay 封面
套件詳情v0.5.0

loading_overlay

一個淡入淡出的模態進度指示器小部件。將其包圍在另一個小部件周圍,以在異步呼叫期間阻止對小部件的存取。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2萬
喜歡數
192
Pub 分數
150

安裝套件

flutter pub add loading_overlay

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,提供了一個模態進度指示器元件,設計為平滑地淡入淡出。它包裝任何元件,在異步操作(例如 API 呼叫或資料處理)期間暫時阻擋使用者互動。非常適合在不中斷 UI 流程的情況下顯示載入狀態。該覆蓋層可透過程式碼控制,提供一種乾淨且可自訂的方式來指示多個平台上的持續任務。

適用情境

  • 在 API 請求期間顯示加載狀態
  • 在資料處理期間阻止UI
  • 改進異步操作期間的使用者體驗
  • 在表單中提供視覺反饋
  • 在應用程式中管理後台任務
  • 增強網頁和行動應用的回應能力

主要特色

  • 平滑的淡入/淡出動畫
  • 可程式化覆疊層控制
  • 支援所有主要平台
  • 與現有組件的輕鬆整合
  • 可自定外觀
  • 非阻塞的父級 widget 在非活動狀態下的互動

適合對象

  • 開發響應式 Flutter 應用的開發者
  • 注重用戶體驗的團隊
  • 需要清晰加載指示器的應用程式
  • 跨平台應用程式
  • UI密集型應用
  • 使用非同步工作流程的專案

使用建議

  • 可能需要小心的狀態管理
  • 疊加層可見性必須手動切換
  • 對複雜UI的效能影響
  • 高級樣式的自定義選項有限
  • 不適用於持續加載狀態
  • 依賴於正確的控件樹結構

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

loading_overlay

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

Started as a fork of modal_progress_hud Inspired by this article.

Demo

Demo

See example for details

Usage

Add the package to your pubspec.yml file.

dependencies:
  loading_overlay: ^0.4.0

Next, import the library into your widget.

import 'package:loading_overlay/loading_overlay.dart';

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

...
bool _isSaving_ = false
...

@override
Widget build(BuildContext context) {
  return Scaffold(
     body: LoadingOverlay(
      color: Colors.black.withOpacity(0.5),
      child: Container(
       Form(...)
      ),
      isLoading: _isSaving_
      ),
  );
}

Alternatively, show the overlay until a Future completes (non-breaking new feature):

// Start an async operation
final saveFuture = _saveFormAsync();

return LoadingOverlay.withFuture(
  future: saveFuture,
  color: Colors.black.withOpacity(0.5),
  child: Form(...),
);

Options

The current parameters are customizable in the constructor

LoadingOverlay({
  required bool isLoading,
  required Widget child,
  Widget progressIndicator = const CircularProgressIndicator(),
  Color? color,
});

// New: show overlay until a Future completes
LoadingOverlay.withFuture({
  required Future<void> future,
  required Widget child,
  Widget progressIndicator = const CircularProgressIndicator(),
  Color? color,
});

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!

所屬分類

原始碼儲存庫

使用此套件的專案