English | 简体中文
连接并操作智能手写本的Flutter插件
- 扫描设备
- 连接设备
- 接收实时笔迹
let device = notepadConnector.requestDevice();
console.log(`requestDevice ${device}`);
let scanResultReceiver = function (scanResult) {
console.log(`onScanResult ${scanResult}`);
};
notepadConnector.onScanResult(scanResultReceiver);
notepadConnector.startScan();
// ...
notepadConnector.stopScan();
notepadConnector.offScanResult(scanResultReceiver);
连接从notepadConnector.requestDevice()
中获取的device
或从notepadConnector.scanResultStream
中扫描到的result
let connectionChangeHandler = function (notepadClient, connectionState) {
console.log(`onConnectionChange ${notepadClient}, ${connectionState}`);
};
notepadConnector.onConnectionChange(connectionChangeHandler);
notepadConnector.connect(obj); // obj = device/scanResult
// ...
notepadConnector.disconnect();
notepadConnector.offConnectionChange(connectionChangeHandler);
-
NotepadMode.Common
设备仅保存压力>0的
NotePenPointer
(含时间戳)到离线字迹中 -
NotepadMode.Sync
设备发送所有
NotePenPointer
(无时间戳)到连接的手机/Pad上
设备默认为NotepadMode.Common
(连接/未连接),只有连接后setMode
才会更改
await _notepadClient.setMode(NotepadMode.Sync);
console.log("setMode complete");
当NotepadMode.Sync
时,接收NotePenPointer
let syncPointerReceiver = function (pointers) {
console.log(`onSyncPointerReceive ${pointers.length}`);
};
_notepadClient.onSyncPointerReceive(syncPointerReceiver);
// ...
_notepadClient.offSyncPointerReceive(syncPointerReceiver);