Added connection checks

development^2
FaizHashmiCS22 10 months ago
parent ca664cda0f
commit 366541f20f

@ -27,16 +27,14 @@ class MyHttpOverrides extends HttpOverrides {
class API {
static getCallRequestInfoByClinicInfo(String deviceIp,
{required Function(List<PatientTicketModel>, List<PatientTicketModel>, CallConfig callConfig) onSuccess,
required Function(dynamic) onFailure}) async {
{required Function(List<PatientTicketModel>, List<PatientTicketModel>, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async {
final body = {"ipAdress": deviceIp, "apiKey": apiKey};
bool isDevMode = false;
if (isDevMode) {
final Map<String, dynamic> response = testPatientsData["data"] as Map<String, dynamic>;
CallConfig callConfig = CallConfig.fromJson(response["callConfig"]);
var callPatients =
(response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).toList();
var callPatients = (response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).toList();
var isQueuePatients = callPatients.where((element) => (element.isQueue == false && element.callType != 0)).toList();
log("callPatients: ${callPatients.toString()}");
log("isQueuePatients: ${isQueuePatients.toString()}");
@ -50,11 +48,7 @@ class API {
final response = apiResp["data"];
CallConfig callConfig = CallConfig.fromJson(response["callConfig"]);
var callPatients = (response["callPatients"] as List)
.map((j) => PatientTicketModel.fromJson(j))
.toList()
.where((element) => element.callType != 0)
.toList();
var callPatients = (response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).toList();
var isQueuePatients = callPatients.where((element) => (element.isQueue == false && element.callType != 0)).toList();
callPatients.sort((a, b) => a.editedOnTimeStamp.compareTo(b.editedOnTimeStamp));
@ -108,7 +102,10 @@ class API {
body: body,
onSuccess: (response, status) {
if (status == 200 && response["data"] != null) {
widgetsConfigModel = (response["data"] as List).map((e) => WidgetsConfigModel.fromJson(e)).toList().first;
List list = (response["data"] as List).map((e) => WidgetsConfigModel.fromJson(e)).toList();
if (list.isNotEmpty) {
widgetsConfigModel = list.first;
}
}
},
onFailure: (error, status) => log("error: ${error.toString()}"));

@ -25,7 +25,18 @@ bool isVoiceActualCompletedGlobally = false;
class AppProvider extends ChangeNotifier {
AppProvider() {
callInitializations();
waitForIPAndCallInitializations();
}
Future<void> waitForIPAndCallInitializations() async {
while (currentDeviceIp == "") {
await getCurrentIP();
if (currentDeviceIp != "") {
callInitializations();
} else {
await Future.delayed(const Duration(seconds: 2));
}
}
}
Future<void> callInitializations() async {
@ -226,6 +237,9 @@ class AppProvider extends ChangeNotifier {
// if (currentWidgetsConfigModel == null) return;
await getInfoWidgetsConfigurationsFromServer().whenComplete(() async {
if (currentWidgetsConfigModel == null) {
return;
}
if (currentWidgetsConfigModel!.isWeatherReq != null && currentWidgetsConfigModel!.isWeatherReq!) {
await getWeatherDetailsFromServer();
}

@ -35,15 +35,15 @@ dependencies:
provider: ^6.0.1
get_it: ^8.0.2
connectivity_plus: ^6.1.0
# flutter_gifimage: ^1.0.1
# flutter_gifimage: ^1.0.1
flutter_svg: ^2.0.14
http: ^1.2.2
blinking_text: ^1.0.2
just_audio: ^0.9.42
flutter_tts: ^4.1.0
# flutter_tts: ^4.0.2
# flutter_tts: ^4.0.2
wakelock_plus: ^1.2.8
shared_preferences: ^2.2.1
shared_preferences: ^2.3.5
#signalr core
signalr_core: ^1.1.1
intl: ^0.19.0

Loading…
Cancel
Save