Reputation: 1
while requesting permission on initial stage my app crashes but when user allows the permission after daly of some time my app crashes.I'm calling this two functions on init. Error while getting crashed
java.lang.IllegalStateException: Reply already submitted
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:435)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:272)
at how.virc.flutter_esp_ble_prov.BleScanManager$call$1.scanCompleted(FlutterEspBleProvPlugin.kt:255)
at com.espressif.provisioning.device_scanner.BleScanner.stopScan(BleScanner.java:144)
at com.espressif.provisioning.device_scanner.BleScanner$1.run(BleScanner.java:161)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8893)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
This is my code.
void startListeningToScannedResults() async {
// Check platform support and necessary requirements
final can = await WiFiScan.instance.canGetScannedResults(askPermissions: true);
switch (can) {
case CanGetScannedResults.yes:
// Check if the subscription is null before creating a new one
if (subscription == null) {
subscription = WiFiScan.instance.onScannedResultsAvailable.listen((results) {
accessPoints = results;
uniqueWifiList.value = <dynamic>{...accessPoints.map((WiFiAccessPoint) => WiFiAccessPoint.ssid)}.where((ssid) => ssid != null).cast<String>().toList();
if (selectedWifiName.value == '') {
selectedWifiName.value = uniqueWifiList[0];
}
});
}
break;
// Handle other cases as needed
}
}
void scanBleDevices() async {
final prefix = deviceNamecontroller.text;
print("PREFIX : $prefix");
if (isSetupButtonPressed.value) {
print("Scan operation already in progress");
return;
}
try {
isSetupButtonPressed.value = true;
final scannedDevices = await _flutterEspBleProvPlugin.scanBleDevices(prefix);
bleDevicesList.value = scannedDevices;
if (selectedDeviceName.value.isEmpty && bleDevicesList.isNotEmpty) {
selectedDeviceName.value = bleDevicesList.first;
}
} catch (error) {
// Handle any errors that occur during BLE scanning
print("Error during BLE scanning: $error");
Get.snackbar(
"Error",
"Failed to scan BLE devices: $error",
snackPosition: SnackPosition.BOTTOM,
);
} finally {
// Reset the flag indicating that the scan operation is complete
isSetupButtonPressed.value = false;
}
}
I am integrating ESP Ble Provisioning I just want to get user permission and then it should work properly
Upvotes: 0
Views: 354