cameraLogin method
Implementation
@override
Future<Map<String, dynamic>> cameraLogin(String cameraId) async {
if (isRequestPending) {
return {
"isError": true,
"message": "PENDING_PREVIOUS_REQUEST",
"details": "Called cameraLogin()"
};
}
try {
isRequestPending = true;
final apiResponse = await apiService.getDeviceMasterAccount(cameraId);
if (apiResponse['isError']) return apiResponse;
final account = apiResponse["account"];
await methodChannel.invokeMethod('LOGIN', {
"userName": account["username"],
"password": account["password"],
});
await methodChannel.invokeMethod('CAMERA_LOGIN', {"cameraId": cameraId});
initializedCamera = cameraId;
isRequestPending = false;
isUserLogged = true;
return {
"isError": false,
"message": "Camera Logged in",
};
} catch (e) {
isRequestPending = false;
if (e is PlatformException) {
return {"isError": true, "message": e.message};
}
return {"isError": true, "message": "Error: $e"};
}
}