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

screen_loader のカバー
パッケージ詳細v4.0.1

screen_loader

状態やナビゲーションスタックを使用せずに、画面の読み込みを処理する簡単なミックスイン ScreenLoader。ロードのカスタマイズも可能です。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1470
いいね数
50
Pub ポイント
150

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

flutter pub add screen_loader

パッケージ概要

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

ScreenLoader は、明示的な状態管理やナビゲーションスタックの操作を必要とせずに、画面内のロード状態を管理するためのシンプルなミックスインを提供する Flutter/Dart パッケージです。最小限のボイラープレートで、スクリーン間でローディングインジケーターを表示および制御できます。ローディングUIのカスタマイズをサポートしており、さまざまなデザインニーズに適応可能です。複数のウィジェットで一貫性があり再利用可能なロード体験が必要なアプリに最適です。

用途

  • 非同期操作中にロードオーバーレイを表示する
  • フォーム内の読み込み状態管理の簡素化
  • API 呼び出しにローディングインジケーターを追加する
  • 再利用可能な読み込みコンポーネントの作成
  • スムーズな読み込み遷移によるUXの向上
  • スクリーンレベルのロードロジックにおけるボイラープレートの削減

主な機能

  • ミックスインベースの読み込み実装
  • カスタマイズ可能な読み込み UI
  • 状態管理の必要はありません
  • すべてのプラットフォームで動作します
  • 最小限のセットアップが必要
  • 非同期操作の処理をサポートしています

適している対象

  • 軽量なロードソリューションを求める開発者
  • 最小限の状態管理を使用するチーム
  • 頻繁な非同期データ取得を持つアプリ
  • 一貫したローダーを必要とするUI重視のアプリケーション
  • Flutterの初心者がロードパターンを探求しています
  • 複数のデバイスをターゲットとしたクロスプラットフォームアプリ

注意事項

  • 基本的な読み込み機能に限定
  • 非同期ワークフローとの手動統合が必要です
  • 複雑な読み込み状態には適していません
  • カスタムデザイン用に追加のスタイルが必要になる場合があります
  • 正しいウィジェットツリー構造に依存する
  • デフォルトではエラー状態を処理しない

元の README

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

screen_loader

Why ScreenLoader?

  1. With the help of stream_mixin, it shows and hides the loader without updating the state of the widget which increases the performance
  2. It does not push any sort of widget to navigation stack, this helps in not messing up the navigation stack and context
  3. Easy to use, just use your screen with ScreenLoader mixin and wrap the widget with loadableWidget
  4. The loader is customizable. You can use any widget as a loader
  5. You can configure same loader for all the screens at once
  6. You can also configure different loader for different screens

Basic usage

  1. Use your screen with the ScreenLoader mixin
  2. Wrap the widget with loadableWidget
  3. Use performFuture function to show loader while your future is being performed

Configure different loader for individual screen

Simply overide loader() method

loader() {
    // here any widget would do
    return AlertDialog(
        title: Text('Wait.. Loading data..'),
    );
}

Configure the loader for all screens at once

void main() {
  configScreenLoader(
    loader: AlertDialog(
      title: Text('Gobal Loader..'),
    ),
    bgBlur: 20.0,
  );
  runApp(MyApp());
}

Priority of loaders (highest first)

  • Local loader: the one you override in your widget
  • Global loader: the one you specify in configScreenLoader. Note: if you don't override local(), this loader will be used
  • Default loader: if you don't specify global loader or override local loader, this loader will be used

Migration guide to 4.0.0

  1. ScreenLoaderApp widget is removed. Now no need to wrap your App around any widget just to set the global configurations. Instead call configScreenLoader() before runApp()
-void main() => runApp(MyApp());
+void main() {
+  configScreenLoader(
+    loader: AlertDialog(
+      title: Text('Gobal Loader..'),
+    ),
+    bgBlur: 20.0,
+  );
+  runApp(MyApp());
+}
 
 class MyApp extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
-    return ScreenLoaderApp(
-      app: MaterialApp(
-        debugShowCheckedModeBanner: false,
-        title: 'Screen Loader',
-        theme: ThemeData(
-          primarySwatch: Colors.blue,
-        ),
-        home: Screen(),
-      ),
-      globalLoader: AlertDialog(
-        title: Text('Gobal Loader..'),
+    return MaterialApp(
+      debugShowCheckedModeBanner: false,
+      title: 'Screen Loader',
+      theme: ThemeData(
+        primarySwatch: Colors.blue,
       ),
-      globalLoadingBgBlur: 20.0,
+      home: Screen(),
     );
   }
 }
  1. Instead of replacing the build function with screen use the build function itself and wrap the widget you want to show loader on with the loadableWidget.

-class _ScreenState extends State<Screen> with ScreenLoader<Screen> {
+class _ScreenState extends State<Screen> with ScreenLoader {
   @override
   loader() {
     return AlertDialog(
@@ -49,17 +51,19 @@ class _ScreenState extends State<Screen> with ScreenLoader<Screen> {
   }
 
   @override
-  Widget screen(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(
-        title: Text('ScreenLoader Example'),
-      ),
-      body: _buildBody(),
-      floatingActionButton: FloatingActionButton(
-        onPressed: () async {
-          await this.performFuture(NetworkService.getData);
-        },
-        child: Icon(Icons.refresh),
+  Widget build(BuildContext context) {
+    return loadableWidget(
+      child: Scaffold(
+        appBar: AppBar(
+          title: Text('ScreenLoader Example'),
+        ),
+        body: _buildBody(),
+        floatingActionButton: FloatingActionButton(
+          onPressed: () async {
+            await this.performFuture(NetworkService.getData);
+          },
+          child: Icon(Icons.refresh),
+        ),
       ),
     );
   }

PS
  • PRs are welcome
  • Please raise issues on https://github.com/arnold-parge/screen_loader.
  • Open for suggestions ❤️

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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

データはまだありません。