Skip to content

Instantly share code, notes, and snippets.

@Wenomok
Created April 5, 2023 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wenomok/98b40e90e6095cf42d266053fe2fa930 to your computer and use it in GitHub Desktop.
Save Wenomok/98b40e90e6095cf42d266053fe2fa930 to your computer and use it in GitHub Desktop.
class HubManager {
static const double SCAN_WIFI_TIMEOUT = 60.0;
//1
static const _platform = MethodChannel('dexbee.club/HubConfig');
Future<List<WiFiHubModel>> scanWiFiHubList({double timeout = FitBleKitManager.SCAN_WIFI_TIMEOUT}) async {
try {
List<WiFiHubModel> wifiModelList = [];
//2
List<dynamic> result = await _platform.invokeMethod(
'scanWiFiHubList',
{
'timeout': timeout
}
);
//3
for(Map<dynamic, dynamic> wifiResult in result) {
WiFiHubModel? wifiHubModel = WiFiHubModel.parseResult(wifiResult);
if(wifiHubModel != null) {
wifiModelList.add(wifiHubModel);
}
}
return wifiModelList;
} catch(e) {
print(e);
throw e;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment