flutter_bluetooth_basic
Flutter 插件。允许查找蓝牙设备并发送原始字节数据
- 星标
- 41
- 复刻
- 170
- 最近推送(UTC)
- 2022年9月10日
- 项目状态
- 未归档
原始 README
以下为英文项目原文快照,最新内容请访问 GitHub。
flutter_bluetooth_basic
Flutter plugin that allows to find bluetooth devices & send raw bytes data. Supports both Android and iOS.
Inspired by bluetooth_print.
Main Features
- Android and iOS support
- Scan for bluetooth devices
- Send raw
List<int> bytesdata to a device
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.
BluetoothManager bluetoothManager = BluetoothManager.instance;
BluetoothDevice _device;
bluetoothManager.startScan(timeout: Duration(seconds: 4));
bluetoothManager.state.listen((state) {
switch (state) {
case BluetoothManager.CONNECTED:
// ...
break;
case BluetoothManager.DISCONNECTED:
// ...
break;
default:
break;
}
});
// bluetoothManager.scanResults is a Stream<List<BluetoothDevice>> sending the found devices.
// _device = <from bluetoothManager.scanResults>
await bluetoothManager.connect(_device);
List<int> bytes = latin1.encode('Hello world!\n').toList();
await bluetoothManager.writeData(bytes);
await bluetoothManager.disconnect();
See also
- Example of usage in a project: esc_pos_printer
语言JavaObjective-CDartRuby
使用的依赖
依赖清单 6 项
- flutter
{"sdk":"flutter"} - json_annotation
^4.1.0 - rxdart
^0.26.0 - flutter_test开发依赖
{"sdk":"flutter"} - build_runner开发依赖
^1.0.0 - json_serializable开发依赖
^3.2.2
如何选择适合项目的代码仓?
先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
- 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
- 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
- 使用前在 GitHub 核对 README、许可证与 Issues。
来源与维护
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗