wwandreww/flutter_bluetooth_basic
Flutter 플러그인. 블루투스 장치를 검색하고 원시 바이트 데이터를 전송할 수 있습니다
- Stars
- 41
- Forks
- 170
- 최근 푸시(UTC)
- 2022. 9. 10.
- 프로젝트 상태
- 활성
언어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
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
README 펼치기 / 접기
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