update
feat(api_service): Update try-catch funtion and handle exception update(loading_animation): Update loading animation using Lottie
This commit is contained in:
@@ -93,30 +93,34 @@ class DeviceUtils {
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
Future<String> getFullDeviceLocation(
|
||||
BuildContext context, String areaPath) async {
|
||||
if (areaPath != "") {
|
||||
BuildContext context, String areaPath, String? deviceName) async {
|
||||
if (areaPath.isNotEmpty) {
|
||||
List<String> parts = areaPath.split('_');
|
||||
|
||||
if (parts.length < 3 || parts[0].isEmpty || parts[1].isEmpty || parts[2].isEmpty) {
|
||||
if (deviceName != null && deviceName.isNotEmpty) {
|
||||
return deviceName;
|
||||
} else {
|
||||
return appLocalization(context).no_data_message;
|
||||
}
|
||||
}
|
||||
|
||||
String provinceID = parts[0];
|
||||
String districtID = parts[1];
|
||||
String wardID = parts[2];
|
||||
|
||||
String provinceBody = await apiServices.getProvinceByID(provinceID);
|
||||
final provinceItem = jsonDecode(provinceBody);
|
||||
Province province = Province.fromJson(provinceItem['data']);
|
||||
String districtBody = await apiServices.getDistrictByID(districtID);
|
||||
final districtItem = jsonDecode(districtBody);
|
||||
District district = District.fromJson(districtItem['data']);
|
||||
String wardBody = await apiServices.getWardByID(wardID);
|
||||
final wardItem = jsonDecode(wardBody);
|
||||
Ward ward = Ward.fromJson(wardItem['data']);
|
||||
|
||||
Province province = await apiServices.getProvinceByID(provinceID);
|
||||
District district = await apiServices.getDistrictByID(districtID);
|
||||
Ward ward = await apiServices.getWardByID(wardID);
|
||||
return "${ward.fullName}, ${district.fullName}, ${province.fullName}";
|
||||
}
|
||||
|
||||
return appLocalization(context).no_data_message;
|
||||
}
|
||||
|
||||
|
||||
String checkStateDevice(BuildContext context, int state) {
|
||||
String message = appLocalization(context).no_data_message;
|
||||
if (state == 1) {
|
||||
@@ -157,11 +161,11 @@ class DeviceUtils {
|
||||
} else if (state == 0) {
|
||||
return const Color(0xFF9EF16D);
|
||||
} else if (state == 2) {
|
||||
return const Color(0xFFF5EF44);;
|
||||
return const Color(0xFFF5EF44);
|
||||
} else if (state == -1) {
|
||||
return const Color(0xFFBBBAC2);;
|
||||
return const Color(0xFFBBBAC2);
|
||||
} else {
|
||||
return const Color(0xFFF5EF44);;
|
||||
return const Color(0xFFF5EF44);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user