搜索插件、代码仓与 APP 分类

插件详情v1.1.3

bluetoothadapter

一个 Flutter 插件,用于为 **仅 Android** 暴露蓝牙适配器的功能。

近 30 天下载
63
喜欢数
22
Pub 分数
40

安装插件

flutter pub add bluetoothadapter

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

The bluetoothadapter package is a Flutter plugin that provides access to Bluetooth adapter functionalities on Android devices. It enables developers to check Bluetooth status, enable or disable Bluetooth, and retrieve adapter information. Designed specifically for Android, it offers a straightforward API to interact with the device's Bluetooth hardware, making it ideal for apps requiring low-level Bluetooth control. The plugin does not support iOS, limiting its use to Android-only applications. It integrates seamlessly with Flutter projects via pub.dev.

适合场景

  • 通过编程方式启用/禁用蓝牙
  • 检查蓝牙适配器状态
  • 在仅限 Android 的应用中集成蓝牙功能
  • 开发物联网设备连接解决方案
  • 创建基于蓝牙的近距离检测系统

主要特点

  • 仅限 Android 兼容性
  • 蓝牙适配器控制的简单API
  • 支持启用和禁用蓝牙
  • 提供适配器信息和状态
  • 轻量且易于集成

适合对象

  • 专注于 Android 的移动应用开发者
  • 物联网应用创建者
  • 蓝牙设备集成商
  • 需要直接蓝牙管理的应用
  • 不支持 iOS 的项目

使用建议

  • 不兼容 iOS 平台
  • 仅限 Android 蓝牙适配器功能
  • 需要 Android 特定权限
  • 不支持高级蓝牙LE操作
  • 取决于设备制造商的实现

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

bluetoothadapter

A Flutter plugin to expose the features of Bluetooth Adapter for Android only.

Objective

The primary purpose of this project was to communicate between flutter and Rasburry Pie using Bluetooth.

Main Features

  • Setting up a UUID from user end.
  • Checking Bluetooth connection status and giving alerts if its off or not right.
  • Getting list of paired devices.
  • Get a particular paired device info.
  • Start Bluetooth server.
  • Start Bluetooth client.
  • Start Bluetooth client.
  • Send message to a connected device.
  • Stream for listening to received messages.
  • Stream for listening to connection status (CONNECTED, CONNECTING, CONNECTION FAILED, LISTENING, DISCONNECTED).
Getting Started

For a full example please check /example folder. Here are only the most important parts of the code to illustrate how to use the library.

//Initiatinng the bluetooth adapter
Bluetoothadapter flutterbluetoothadapter = Bluetoothadapter();

//Listening to the connection status listener
String _connectionStatus = "NONE";
StreamSubscription _btConnectionStatusListener =flutterbluetoothadapter.connectionStatus().listen((dynamic status) {
  setState(() {
    _connectionStatus = status.toString();
  });
});

//Listening to the recieved messages
String _recievedMessage;
StreamSubscription _btReceivedMessageListener = flutterbluetoothadapter.receiveMessages().listen((dynamic newMessage) {
  setState(() {
    _recievedMessage = newMessage.toString();
  });
});
Getting paired devices
List<BtDevice> devices = await flutterbluetoothadapter.getDevices();
Getting paired device
await flutterbluetoothadapter.getDevice(deviceAddress);
Starting BT server
await flutterbluetoothadapter.startServer();
Starting BT client
flutterbluetoothadapter.startClient(devices.indexOf(element), true);
Sending message
flutterbluetoothadapter.sendMessage(messageString);
Check BT connection
await flutterbluetoothadapter.checkBluetooth(); //returns bool
Set UUID
flutterbluetoothadapter.initBlutoothConnection(uuid);

所属分类

源码仓库

使用此插件的项目

暂无相关数据。