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

套件詳情v1.0.0+1

permission_asker

permission_handler 的包裝器,可減少我們在應用程式中處理權限所需的大量樣板程式碼。

AndroidiOS
近 30 天下載
4
喜歡數
19
Pub 分數
130

安裝套件

flutter pub add permission_asker

套件介紹

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

Permission_Asker 是一個 Flutter 套件,透過封裝 permission_handler 庫來簡化權限處理。它減少了在 Android 和 iOS 應用中請求和管理權限所需的樣板程式碼,提供更乾淨、更簡潔的 API。該套件簡化了常見的權限工作流程,讓檢查、請求和回應權限狀態變得更容易,無需重複撰寫程式碼。非常適合尋求輕量級解決方案以提升處理裝置權限時程式碼可讀性和可維護性的開發者。

適用情境

  • 在照片應用中請求相機訪問權限
  • 在導航應用中處理位置權限
  • 管理檔案上傳的儲存存取
  • 在錄製前檢查麥克風權限
  • 簡化跨多個螢幕的權限檢查

主要特色

  • 透過乾淨的 API 減少樣板程式碼
  • 無縫包裝 permission_handler
  • 支援 Android 和 iOS 平台
  • 提供便捷的權限狀態檢查
  • 提供直觀的請求方法

適合對象

  • 使用 permission_handler 的開發者
  • 需要頻繁管理權限的應用程式
  • 注重程式碼清晰、可讀性的團隊
  • 旨在減少重複權限邏輯的項目
  • Flutter 初學者學習權限處理

使用建議

  • 需要 permission_handler 作為依賴項
  • 僅限基本權限操作
  • 無內建的UI自訂
  • 不處理複雜的權限流程
  • 取決於底層 permission_handler 的行為

原始 README

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

permission_asker

A wrapper for permission_handler which lifts some of the boilerplate needed to handle permissions in our apps.

Why

Usually, when we need to build our widgets according to the permission status of a certain feature we need to check if the permission is granted or not and ask for it. Since these are async operations we usually need to add some boilerplate to do the right thing at the right time.

What

In addition to everything that's provided with permission_handler by exposing it, this package provides:

  • a PermissionAsker class which allows to ask permissions and react to the results via the onPermissionData callback.
  • a PermissionAskerBuilderclass which allows to build a widget according to the status of a list of permissions

Setup

Check here for setting up your permissions.

Usage

Here's an example on how you can use the PermissionAskerBuilder widget

PermissionAskerBuilder(
  permissions: [
      Permission.location,
      Permission.camera,
  ],
  grantedBuilder: (context) => Center(
      child: Text('All permissions granted!'),
  ),
  notGrantedBuilder: (context, notGrantedPermissions) => Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
            Text('Not granted permissions:'),
            for (final p in notGrantedPermissions) 
              Text(p.toString())
        ],
      ),
  ),
  notGrantedListener: (notGrantedPermissions) => print('Not granted:\n$notGrantedPermissions'),
)

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。