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

套件詳情v0.1.7

bluetooth_enable_fork

Flutter 插件,用於在應用內開啟藍牙

AndroidiOS
近 30 天下載
967
喜歡數
20
Pub 分數
140

安裝套件

flutter pub add bluetooth_enable_fork

套件介紹

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

一個 Flutter 外掛,可在 Android 和 iOS 應用內直接啟用藍牙。它提供了一個簡單的介面來檢查藍牙狀態並請求啟動,幫助應用在需要時引導使用者開啟藍牙。設計為原始 bluetooth_enable 套件的分支,保持相容性,同時可能提供改進或修復。適用於依賴藍牙連接的應用程式,例如信標、物聯網裝置或基於 NFC 的服務。

適用情境

  • 在物聯網應用中啟用藍牙
  • 引導使用者開啟藍牙
  • 與信標檢測整合
  • 支援NFC和近場功能
  • 處理應用程式中的藍牙權限

主要特色

  • 跨平台支援(Android 與 iOS)
  • 用於檢查和啟用藍牙的簡單API
  • 使用者友善的權限處理
  • 帶有潛在修復的分支
  • 輕量且易於整合

適合對象

  • 開發依賴藍牙應用程式的開發者
  • 需要用戶引導的藍牙設定應用程式
  • 物聯網和信標解決方案
  • 需要可靠藍牙狀態管理的移動應用
  • 使用原始 bluetooth_enable 套件的專案

使用建議

  • 需要使用者互動以啟用藍牙
  • 僅限基本藍牙狀態控制
  • 某些平台可能需要額外的權限
  • 取決於底層作業系統藍牙實現
  • 不適用於背景藍牙操作

原始 README

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

Introduction

BluetoothEnable is a Bluetooth plugin for Flutter, to programtically request turning on Bluetooth within applications.

This plugin was created with the intention to allow developers to customise their own application workflow on when permissions are requested.

Usage

Enable Bluetooth
import 'package:bluetooth_enable_fork/bluetooth_enable.dart';

// Request to turn on Bluetooth within an app
BluetoothEnable.enableBluetooth.then((result) {
  if (result == "true") {
    // Bluetooth has been enabled
  }
  else if (result == "false") {
    // Bluetooth has not been enabled
  }
});
Enable Bluetooth with Custom Alert

This method calls an alert from Dart level. Depending on the user's selection, Bluetooth will either be manually turned on without an additional dialog request or nothing happens.

Parameter Description
context The material context of your current content
dialogTitle The title of the dialog is displayed in a large font at the top
displayDialogContent Enable or disable showing dialog content
dialogContent The content of the dialog that is displayed in the center
cancelBtnText The cancel button text of the dialog (left button)
acceptBtnText The accept button text of the dialog (right button)
dialogRadius The border radius of dialog
barrierDismissible Enable or Disable whether dialog is dismissible on external click
import  'package:bluetooth_enable_fork/bluetooth_enable.dart';

Future<void> customEnableBT(BuildContext context) async {
  String dialogTitle = "Hey! Please give me permission to use Bluetooth!";
  bool displayDialogContent = true;
  String dialogContent = "This app requires Bluetooth to connect to device.";
  //or
  // bool displayDialogContent = false;
  // String dialogContent = "";
  String cancelBtnText = "Nope";
  String acceptBtnText = "Sure";
  double dialogRadius = 10.0;
  bool barrierDismissible = true; //

  BluetoothEnable.customBluetoothRequest(context, dialogTitle, displayDialogContent, dialogContent, cancelBtnText, acceptBtnText, dialogRadius, barrierDismissible).then((result) {
    if (result == "true") {
      //Bluetooth has been enabled
    }
  });
}
iOS support

If Bluetooth has not been activated, a popup window will appear on enableBluetooth call asking user to activate Bluetooth in the application settings; the method will immediately return false (but will return true on next call if user enabled Bluetooth in the meantime).

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。