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

uiblock 封面
套件詳情v2.0.3

uiblock

完全可自訂且易於使用的 uiblock 套件,適用於您的 Flutter 應用程式

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1180
喜歡數
53
Pub 分數
150

安裝套件

flutter pub add uiblock

套件介紹

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

一個完全可自訂且易於使用的 Flutter 套件,用於在應用程式中實作 UI 阻擋元件。它提供了一種簡單的方式,透過載入指示器、進度條或自訂小部件覆蓋內容,確保使用者在非同步操作期間獲得通知。非常適合在資料載入或處理期間防止互動,支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。此套件輕量級,設計為可無縫整合至現有的 Flutter 專案中。

適用情境

  • 在資料加載期間阻止UI
  • 顯示自定義加載覆蓋層
  • 在非同步任務期間防止使用者互動
  • 透過視覺反饋提升使用者體驗
  • 實現刷新指示器
  • 建立模態加載螢幕

主要特色

  • 完全可自訂的外觀
  • 快速整合的簡單 API
  • 支援所有 Flutter 平台
  • 可擴展以支援自訂覆疊層
  • 輕量且高效能
  • 內建的載入與進度指示器

適合對象

  • 尋求快速UI阻塞解決方案的開發者
  • 需要一致載入狀態的應用程式
  • 專注於使用者體驗改善的團隊
  • 具有跨平台需求的專案
  • 使用 Flutter 的前端開發人員
  • 頻繁執行非同步操作的應用程式

使用建議

  • 可能需要額外的樣式設定以實現複雜設計
  • 自定疊加層需要手動實作
  • 有限的內建主題
  • 不適用於高頻率更新
  • 依賴於正確的 widget 樹結構
  • 最好與適當的狀態管理搭配使用

原始 README

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

uiblock

pub package publisher pub package GitHub Stars Platform

Buy Me A Coffee

Easiest and simplest method to block/unblock ui for your flutter apps.

One line of code to block/unblock ui and stop user from navigating during loading or processing in your flutter apps. You could use it as a widget or directly as a global service/util.

  • Fully customizable
  • Android and IOS
  • Easy and Simple
  • No other dependencies
  • Well documented
  • Production ready

Installation

With null-safety

      dependencies:
        uiblock: ^2.0.1

Without null-safety

      dependencies:
        uiblock: 1.2.0

Getting Started

Add the dependency to your project and start using uiblock everywhere:

Import the package.

import 'package:uiblock/uiblock.dart';

To block ui

 // default
 UIBlock.block(context);
 
 //OR

 // if using globalKey
 UIBlock.block(_scaffoldGlobalKey.currentContext);

To unblock ui

 // call unblock after blockui to dissmiss
 UIBlock.unblock(context);

 //OR

 // if using globalKey
 UIBlock.unblock(_scaffoldGlobalKey.currentContext);

Using as a widget

//toggle showLoader to block/unblock
FlatButton(
    child: Text('Load Async'),
    onPressed: () {
        setState(() {
            showLoader = !showLoader;
        });
    },
),

 // easily create custom block ui body
 Container(
    height: _height,
    child: UIBlock(
        loadingStateFromFuture: () async {
        if (showLoader) {
            // return null, to block ui
            return null;
        }
        // unblocks ui on hasData or hasError
        return Future.value(Random().nextInt(200));
        },
        barrierColor: Colors.blueGrey,
        barrierOpacity: 0.2,
        loadingTextWidget: Text('Loading data...'),
        hideBuilderOnNullData: true,
        builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
            return Center(child: Text('Async Data ${snapshot.data}'));
        },
    ),
 );

Blocking with text
UIBlock.block(
    _scaffoldGlobalKey.currentContext,
    canDissmissOnBack: true,
    loadingTextWidget: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Text(
        'Press back to dissmiss',
        textAlign: TextAlign.center,
        style: TextStyle(
            color: Colors.white,
            fontSize: 18.0,
            fontWeight: FontWeight.w600,
        ),
        ),
    ),
);
Creating using child builder
 // easily create custom block ui body
 UIBlock.block(
     _scaffoldGlobalKey.currentContext,
    backgroundColor: Colors.green.withOpacity(0.5),
    imageFilter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
    childBuilder: (BuildContext context) {
        // return your widget here
    },
 );

 // Don't forget to call unblock after block :)
Creating custom block modal transitions (only applicable on static UIBlock.block)
// NOTE : only for on UIBlock.block as this uses Modal Barrier
// widget block is inline widget replacement with loader widget

UIBlock.block(
    //...
    // more code
    customBuildBlockModalTransitions:
        (context, animation, secondaryAnimation, child) {
        return RotationTransition(
            turns: animation,
            child: child,
        );
    },
    // ...
);

Using with data return

// NOTE : canDissmissOnBack is alaways true
 var result = await UIBlock.blockWithData(
           _scaffoldGlobalKey.currentContext,
           loadingTextWidget: Padding(
               padding: const EdgeInsets.all(8.0),
               child: FlatButton(
               onPressed: () {
                   // unblock and return data
                   UIBlock.unblockWithData(context, "hello world");
               },
               child: Text(
                       'Press here to dissmiss with data. Back for null',
                       textAlign: TextAlign.center,
                       style: TextStyle(
                       color: Colors.white,
                       fontSize: 18.0,
                       fontWeight: FontWeight.w600,
                       ),
                   ),
               ),
           ),
       );

   print(result);

For more details have a look at the other examples.

Properties

Property Type Default Note
context (required) BuildContext -
childBuilder Function -
customLoaderChild Widget -
loadingTextWidget Widget -
imageFilter ImageFilter -
backgroundColor Color Transparent
canDissmissOnBack bool false
safeAreaLeft bool true Set as 'false' to disable 'Left' Safe Area
safeAreaTop bool true Set as 'false' to disable 'Top' (usually status bar) Safe Area
safeAreaRight bool true Set as 'false' to disable 'Right' Safe Area
safeAreaBottom bool true Set as 'false' to disable 'Bottom' Safe Area
safeAreaMinimumPadding EdgeInsets EdgeInsets.zero
safeAreaMaintainBottomViewPadding bool false
isSlideTransitionDefault bool true Toggle between slide or fade transition
buildBlockModalTransitions Function - Use this to create custom transition other than fade/slide

Widget Properties

Property Type Default
builder Function you implement it
loadingStateFromFuture Future Function() your future function (APIs,etc)
loaderBuilder Function -
customLoaderChild Widget -
loadingTextWidget Widget -
offset offset -
barrierOpacity double 0.4
barrierColor Color black45
canDismiss bool false
hideBuilderOnNullData bool false

Improve

Help me by reporting bugs, submit new ideas for features or anything else that you want to share.

  • Just write an issue on GitHub. ✏️
  • And don't forget to hit the like button for this package ✌️

More

Check out my other useful packages on pub.dev

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。