onStartScan method
Implementation
@override
Future<List<BlueDeviceInfoModel>> onStartScan(
{Duration? scanDuration, Function(String)? onError}) async {
try {
List listString = await methodChannel.invokeMethod(
PluginConstant.onStartScan,
scanDuration?.inMilliseconds ??
const Duration(seconds: 6).inMilliseconds);
List<BlueDeviceInfoModel> listResult = [];
await Future.forEach(
listString,
(element) => {
listResult.add(BlueDeviceInfoModel.fromJson(
jsonDecode(element.toString())))
});
return listResult;
} on PlatformException catch (e) {
onError?.call(e.message ?? MessageConstant.scanFailed);
LogHelper.error(e, event: PluginConstant.onStartScan);
}
return [];
}