bleUnlocks method

dynamic bleUnlocks({
  1. bool isVibrate = false,
  2. dynamic success(
    1. Map map
    )?,
  3. dynamic foundMultipleDevices(
    1. Map map
    )?,
  4. dynamic fail(
    1. PlatformException e
    )?,
})

开启附近设备

Implementation

bleUnlocks(
    {bool isVibrate = false, //开门成功是否震动
    Function(Map map)? success,
    Function(Map map)? foundMultipleDevices,
    Function(PlatformException e)? fail}) async {
  try {
    String json = await methodChannel.invokeMethod("bleUnlock");
    Map<String, dynamic> map = convert.json.decode(json);
    switch (map['type']) {
      case 'DEVICES':
        if (foundMultipleDevices != null) foundMultipleDevices(map);
        break;
      case 'UNLOCK':
        if (isVibrate) Vibrate().start();
        if (success != null) success(map);

        break;
    }
  } catch (e) {
    if (fail != null) fail(e as PlatformException);
  }
}