搜索插件、代码仓与 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).

所属分类

源码仓库

使用此插件的项目

暂无相关数据。