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

screen_loader 封面
套件詳情v4.0.1

screen_loader

易於使用的 mixin ScreenLoader,可處理螢幕上的載入,而無需使用狀態或導航堆疊。您也可以自訂載入。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1470
喜歡數
50
Pub 分數
150

安裝套件

flutter pub add screen_loader

套件介紹

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

ScreenLoader 是一個 Flutter/Dart 套件,提供簡單的 mix-in 來管理螢幕上的載入狀態,而不需要顯式地進行狀態管理或導航堆疊操作。它讓開發者能夠以最少的樣板程式碼在各個畫面之間顯示和控制載入指示器。該套件支援對載入 UI 的自訂,使其能適應各種設計需求。非常適合需要在多個元件中保持一致且可重複使用的載入體驗之應用程式。

適用情境

  • 在非同步操作期間顯示載入覆蓋層
  • 簡化表單中的加載狀態管理
  • 向 API 調用添加加載指示器
  • 建立可重複使用的載入元件
  • 透過流暢的載入轉換增強使用者體驗
  • 減少螢幕層級載入邏輯中的樣板程式碼

主要特色

  • 基於 Mixin 的載入實作
  • 可自定義的載入 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。