|
|
|
import 'dart:io';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:healthcare_user/common/preloader.dart';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:path/path.dart' as path;
|
|
|
|
|
|
|
|
//const Color primaryColor = Color(0XFF1786A3);
|
|
|
|
const Color primaryColor = Color(0XFF68A85D);
|
|
|
|
const Color secondaryColor = Color(0XFFA0C899);
|
|
|
|
const Color buttonColors = Color(0XFFFFAC1C);
|
|
|
|
const Color greyColor = Color(0XFF8F8E8E);
|
|
|
|
const Color textFieldStartColor = Colors.grey;
|
|
|
|
const Color screenBackgroundColor = Color(0XFFEAF6FF);
|
|
|
|
const Color screenBackgroundColord = Colors.black12;
|
|
|
|
const Color dashboardbackground = Color(0XFFF5F5F5);
|
|
|
|
|
|
|
|
//Color AppBarGradient_1 = Color(0XFF1258F6);
|
|
|
|
Color AppBarGradient_1 = Color(0XFF68A85D);
|
|
|
|
|
|
|
|
TextStyle PreloaderText() {
|
|
|
|
return TextStyle(color: Color(0XFF68A85D));
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle labelTextStyle() {
|
|
|
|
return TextStyle(color: primaryColor, fontSize: 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle labelTextStyleOrderMedicine() {
|
|
|
|
return TextStyle(color: primaryColor, fontSize: 12,fontWeight: FontWeight.bold);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle haveMotorTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: Colors.red, fontSize: 12, fontWeight: FontWeight.bold);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle textButtonStyle() {
|
|
|
|
return TextStyle(color: primaryColor, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle textButtonStyleReports() {
|
|
|
|
return TextStyle(color: Colors.white, fontSize: 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle iconBelowTextStyle() {
|
|
|
|
return TextStyle(fontSize: 10, color: primaryColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle valuesTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle recordDetailsHeading() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle problemTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.red
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle headingsTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: primaryColor
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle startAndStopHeading() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: primaryColor,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Text capacitySuffixText() {
|
|
|
|
return Text('in Ltrs.');
|
|
|
|
}
|
|
|
|
|
|
|
|
Text dimensionSuffixText() {
|
|
|
|
return Text('in fts');
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle dashboardTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle labelTextStyleBold() {
|
|
|
|
return TextStyle(
|
|
|
|
color: primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle serverIssueTextStyle() {
|
|
|
|
return TextStyle(color: Colors.red, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle bottomSheetValuesTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle wrapTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: primaryColor,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle wrapTextStyleBlack() {
|
|
|
|
return TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle withoutWrapTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle bmiTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: primaryColor,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle drawerListItemsTextStyle() {
|
|
|
|
return TextStyle(color: Colors.white);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle drawerHeaderTextStyle() {
|
|
|
|
return TextStyle(color: Colors.white, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle drawerHeaderTextStyleNew() {
|
|
|
|
return TextStyle(color: Colors.black, fontSize: 15);
|
|
|
|
}
|
|
|
|
TextStyle radioHeadingTextStyle() {
|
|
|
|
return TextStyle(color: Colors.white);
|
|
|
|
}
|
|
|
|
TextStyle radioItemsTextStyle() {
|
|
|
|
return TextStyle(color: Colors.white,fontSize: 11);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputDecoration textFormFieldDecoration(IconData icon, var text) {
|
|
|
|
return InputDecoration(
|
|
|
|
filled: true,
|
|
|
|
fillColor: primaryColor,
|
|
|
|
prefixIcon: Icon(
|
|
|
|
icon,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.white)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.white),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.white),
|
|
|
|
),
|
|
|
|
labelText: text,
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: Colors.white, //<-- SEE HERE
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDecoration textFormFieldDecorationGrey(IconData icon, var text) {
|
|
|
|
return InputDecoration(
|
|
|
|
prefixIcon: Icon(
|
|
|
|
icon,
|
|
|
|
color: greyColor,
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: greyColor)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: greyColor),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: greyColor),
|
|
|
|
),
|
|
|
|
labelText: text,
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: greyColor, //<-- SEE HERE
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InputDecoration textFormFieldDecorationBMI(IconData icon, var text) {
|
|
|
|
return InputDecoration(
|
|
|
|
//filled: true,
|
|
|
|
//fillColor: Colors.white,
|
|
|
|
prefixIcon: Icon(
|
|
|
|
icon,
|
|
|
|
color: primaryColor,
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide(color: primaryColor)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: primaryColor),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: primaryColor),
|
|
|
|
),
|
|
|
|
labelText: text,
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: Colors.grey, //<-- SEE HERE
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final GlobalKey<State> preloaderWindowKey = new GlobalKey<State>();
|
|
|
|
Future<void> preloaderWindow(BuildContext context) async {
|
|
|
|
try {
|
|
|
|
Dialogs.showLoadingDialog(context, preloaderWindowKey);
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AppSettings {
|
|
|
|
static SharedPreferences sharedPreferences =
|
|
|
|
SharedPreferences.getInstance() as SharedPreferences;
|
|
|
|
static String userName = '';
|
|
|
|
static String userAddress = '';
|
|
|
|
static String detailedAddress = '';
|
|
|
|
static String emergencyContactNumber1 = '';
|
|
|
|
static String emergencyContactNumber2 = '';
|
|
|
|
static String emergencyRelation1 = '';
|
|
|
|
static String emergencyRelation2 = '';
|
|
|
|
static String emergencyRelationName1 = '';
|
|
|
|
static String emergencyRelationName2 = '';
|
|
|
|
static String bloodGroup = '';
|
|
|
|
static String email = '';
|
|
|
|
static String age = '';
|
|
|
|
static String gender = '';
|
|
|
|
static String phoneNumber = '';
|
|
|
|
static String accessToken = '';
|
|
|
|
static String customerId = '';
|
|
|
|
static double userLatitude = 0;
|
|
|
|
static double userLongitude = 0;
|
|
|
|
static String customerIdsign = '';
|
|
|
|
static String profileImage = '';
|
|
|
|
static List<String> storedPreferenceValidKeys = ['username', 'access_token'];
|
|
|
|
static String preloadText = 'Please wait';
|
|
|
|
static String latitude = '';
|
|
|
|
static String longitude = '';
|
|
|
|
static bool servicestatus = false;
|
|
|
|
static bool haspermission = false;
|
|
|
|
static late LocationPermission permission;
|
|
|
|
static late Position position;
|
|
|
|
static String long = "", lat = "";
|
|
|
|
late StreamSubscription<Position> positionStream;
|
|
|
|
static String fcmId = '';
|
|
|
|
static String originalQrCode = '';
|
|
|
|
static String qrCode = '';
|
|
|
|
static String serverToken =
|
|
|
|
'AAAAA66BLaA:APA91bHcmbyiNN8hCL-t-M9oH-u7ZMOl74fcImMM2DQZLgdyY98Wu9XxME-CTPcjpjU6Yy48ouxISrOMb9lpa3PJofh8qciUKMNxV2al-bDvGvPP_VVaH0mrTHzR56hdkGy1Zl-0frDO';
|
|
|
|
|
|
|
|
//api urls
|
|
|
|
//static String host = 'http://35.200.129.165:4000/api/';
|
|
|
|
static String host = 'http://cloudh.in:4000/api/';
|
|
|
|
static String loginUrl = host + 'login';
|
|
|
|
static String signUpUrl = host + 'users';
|
|
|
|
static String generateQRCodeUrl = host + 'generate-qrcode';
|
|
|
|
static String sendSmsUrl = host + 'sendSms';
|
|
|
|
static String phoneVerificationUrl = host + 'phone';
|
|
|
|
static String forgotPasswordUrl = host + 'forgotpassword';
|
|
|
|
static String resetPasswordUrl = host + 'resetpassword';
|
|
|
|
static String verifyPhnUrl = host + 'phone';
|
|
|
|
static String resetTokenUrl = host + 'reset_token';
|
|
|
|
static String bmiCaluculateUrl = host + 'insertBMI';
|
|
|
|
static String bpCaluculateUrl = host + 'insertBP';
|
|
|
|
static String sugarCaluculateUrl = host + 'insertSugar';
|
|
|
|
static String profilePicUrl = host + 'users/profile-picture';
|
|
|
|
static String inviteFriendUrl = host + 'sendInviteLink';
|
|
|
|
static String updateProfileUrl = host + 'update/currentUser';
|
|
|
|
static String updateLocationUrl = host + 'updateLocation';
|
|
|
|
static String updatePinUrl = host + 'updateUserProfile';
|
|
|
|
static String uploadPicUrl = host + 'uploads';
|
|
|
|
static String uploadBloodGroupPicUrl = host + 'uploads-bloodGroup';
|
|
|
|
static String getBmiHistoryUrl = host + 'usersbmi';
|
|
|
|
static String getBpHistoryUrl = host + 'usersbp';
|
|
|
|
static String getSugarHistoryUrl = host + 'userssugar';
|
|
|
|
static String addMedicineTimingsUrl = host + 'medicine-timing';
|
|
|
|
static String updateMedicineTimingsUrl = host + 'update-medicine-timing';
|
|
|
|
static String getMedicineTimingsUrl = host + 'getmedicineztiming';
|
|
|
|
static String findingsUploadPicUrl = host + 'uploads-findings-prescription';
|
|
|
|
static String addFindingsUrl = host + 'update-uploads-findingsPictureId-prescription';
|
|
|
|
static String addReportsUrl = host + 'update-uploads-reportsPictureId-prescription';
|
|
|
|
static String addPrescriptionsUrl = host + 'update-uploads-prescriptionPictureId-prescription';
|
|
|
|
static String updateFindingsUploadPicUrl = host + 'update-uploads-findings-prescription';
|
|
|
|
static String updateReportsUploadPicUrl = host + 'update-uploads-reports-prescription';
|
|
|
|
static String reportsUploadPicUrl = host + 'uploads-reports-prescription';
|
|
|
|
static String prescriptionUploadPicUrl = host + 'uploads-prescription-prescription';
|
|
|
|
static String updatePrescriptionPicUrl = host + 'update-uploads-prescription-prescription';
|
|
|
|
static String recordPrescriptionsUploadPicUrl = host + 'uploads-prescription-prescription';
|
|
|
|
static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist';
|
|
|
|
static String getAllQuotationRequestsUrl = host + 'userprecription';
|
|
|
|
static String getQuotationUrl = host + 'submitPicture';
|
|
|
|
static String addPrescriptionUrl = host + 'add-prescription-details';
|
|
|
|
static String addRecordsUrl = host + 'add-record';
|
|
|
|
static String updateRecordsUrl = host + 'records';
|
|
|
|
static String reportMySelfVideoUploadUrl = host + 'reportProblemVideo';
|
|
|
|
static String uploadReportMyselfPictureUrl = host + 'reportProblemPicture';
|
|
|
|
|
|
|
|
//static String getAllPrescriptionsDataUrl = host + 'usersinglerprecription';
|
|
|
|
static String getAllPrescriptionsDataUrl = host + 'getAllPrescriptionDetails';
|
|
|
|
static String getRecordsDataUrl = host + 'getAllRecords';
|
|
|
|
static String deleteRecordUrl = host + 'deleteRecord';
|
|
|
|
static String deleteFindingsUrl = host + 'delete-uploads-findings';
|
|
|
|
static String deletePrescriptionsUrl = host + 'delete-prescription';
|
|
|
|
static String deleteReportsUrl = host + 'delete-report';
|
|
|
|
static String deleteRecordsUrl = host + 'delete-url';
|
|
|
|
static String deleteBMIDetailsUrl = host + 'deleteBMI';
|
|
|
|
static String deleteBPDetailsUrl = host + 'deleteBP';
|
|
|
|
static String deleteSugarDetailsUrl = host + 'deleteSugar';
|
|
|
|
static String addReportMySelfProblemUrl = host + 'insertReport';
|
|
|
|
static String getAllReportProblemDetalisUrl = host + 'userreport';
|
|
|
|
static String deleteReportMySelfProblemUrl = host + 'deleteReportProblem';
|
|
|
|
static String getAllConnectedDoctorsDataUrl = host + 'connected-doctors';
|
|
|
|
static String addDoctorUrl = host + 'user/connect-doctors';
|
|
|
|
static String getDynamicCodeDataUrl = host + 'getDoctorInfo';
|
|
|
|
|
|
|
|
|
|
|
|
static File? updatedImage;
|
|
|
|
static String image = '';
|
|
|
|
static String profilePictureUrl = '';
|
|
|
|
static String bloodGroupPictureUrl = '';
|
|
|
|
static var api = {
|
|
|
|
'signIn': host + '/login',
|
|
|
|
};
|
|
|
|
|
|
|
|
/*Formatter*/
|
|
|
|
static String formNum(String s) {
|
|
|
|
var comma = NumberFormat('#,##,###', 'en_IN');
|
|
|
|
return comma.format(
|
|
|
|
int.parse(s),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static String formDouble(String s) {
|
|
|
|
var comma = NumberFormat('#,##,###.##', 'en_IN');
|
|
|
|
return comma.format(
|
|
|
|
double.parse(s),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Preloader */
|
|
|
|
static GlobalKey<State> preLoaderKey = new GlobalKey<State>();
|
|
|
|
static Future<void> preLoaderDialog(BuildContext context) async {
|
|
|
|
try {
|
|
|
|
preLoaderKey = new GlobalKey<State>();
|
|
|
|
Dialogs.showLoadingDialog(context, preLoaderKey);
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
////request headers with content type
|
|
|
|
static Future<Map<String, String>> buildRequestHeaders() async {
|
|
|
|
Map<String, String> _headers = new Map<String, String>();
|
|
|
|
_headers[HttpHeaders.contentTypeHeader] = 'application/json';
|
|
|
|
_headers['Authorization'] = accessToken;
|
|
|
|
return _headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
//request headers without content type
|
|
|
|
static Future<Map<String, String>> buildPutRequestHeaders() async {
|
|
|
|
Map<String, String> _headers = new Map<String, String>();
|
|
|
|
_headers['Authorization'] = accessToken;
|
|
|
|
return _headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<Map<String, String>>
|
|
|
|
buildPutRequestHeadersForResetToken() async {
|
|
|
|
Map<String, String> _headers = new Map<String, String>();
|
|
|
|
return _headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shared preferences save,get and clear data
|
|
|
|
static saveData(String _key, _value, type) async {
|
|
|
|
sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
if (type == 'STRING') {
|
|
|
|
await sharedPreferences.setString(_key, _value.toString());
|
|
|
|
} else if (type == 'INTEGER') {
|
|
|
|
await sharedPreferences.setInt(_key, _value);
|
|
|
|
} else if (type == 'BOOL') {
|
|
|
|
await sharedPreferences.setBool(_key, _value);
|
|
|
|
} else if (type == 'DOUBLE') {
|
|
|
|
await sharedPreferences.setDouble(_key, _value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static getData(String _key, type) async {
|
|
|
|
sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
if (type == 'STRING') {
|
|
|
|
return sharedPreferences.getString(_key) ?? '';
|
|
|
|
} else if (type == 'INTEGER') {
|
|
|
|
return sharedPreferences.getInt(_key) ?? -1;
|
|
|
|
} else if (type == 'BOOL') {
|
|
|
|
return sharedPreferences.getBool(_key) ?? -1;
|
|
|
|
} else if (type == 'DOUBLE') {
|
|
|
|
return sharedPreferences.getDouble(_key) ?? -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static clearSharedPrefeences() async {
|
|
|
|
sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
await sharedPreferences.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Sign in check*/
|
|
|
|
static Future<bool> isSigIn() async {
|
|
|
|
bool isSignInCheck = true;
|
|
|
|
for (var eachKey in storedPreferenceValidKeys) {
|
|
|
|
if (await getData(eachKey, 'STRING') == '') {
|
|
|
|
isSignInCheck = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isSignInCheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> internetConnectivity() async {
|
|
|
|
try {
|
|
|
|
final result = await InternetAddress.lookup('google.com');
|
|
|
|
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} on SocketException catch (_) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Apis Starts here*/
|
|
|
|
|
|
|
|
static Future<bool> login(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(loginUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response['simplydata']['error']);
|
|
|
|
|
|
|
|
if (_response['simplydata']['error'] == false) {
|
|
|
|
await saveAvailableReportAndLocationsInMemory(_response);
|
|
|
|
//await saveProfilePic(_response);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> signUp(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(signUpUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
customerIdsign = _response['armintahealthdata']['customerId'];
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> generateQRCode() async {
|
|
|
|
var uri = Uri.parse(generateQRCodeUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.post(uri, headers: await buildPutRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri, headers: await buildPutRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> sendSms(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(sendSmsUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> phoneVerification(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(phoneVerificationUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> forgotPassword(payload) async {
|
|
|
|
var uri = Uri.parse(forgotPasswordUrl);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> resetPassword(payload) async {
|
|
|
|
var uri = Uri.parse(resetPasswordUrl);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> calculateBmi(payload) async {
|
|
|
|
var uri = Uri.parse(bmiCaluculateUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> calculateBP(payload) async {
|
|
|
|
var uri = Uri.parse(bpCaluculateUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> calculateSugar(payload) async {
|
|
|
|
var uri = Uri.parse(sugarCaluculateUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> resetToken() async {
|
|
|
|
var uri = Uri.parse(resetTokenUrl + '/' + customerId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
// var response = await http.get(uri, headers: await buildPutRequestHeaders());
|
|
|
|
var response = await http.get(uri,
|
|
|
|
headers: await buildPutRequestHeadersForResetToken());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
print(response.body);
|
|
|
|
var res = jsonDecode(response.body);
|
|
|
|
print(res);
|
|
|
|
|
|
|
|
accessToken = res['access_token'];
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> verifyPhn(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(verifyPhnUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
if (_response['armintahealthdata']['error'] == false) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> updateProfilePicture(payload) async {
|
|
|
|
var uri = Uri.parse(profilePicUrl + '/' + customerId);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> inviteFriend(payload) async {
|
|
|
|
|
|
|
|
var uri = Uri.parse(inviteFriendUrl);
|
|
|
|
uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> updateProfile(payload) async {
|
|
|
|
var uri = Uri.parse(updateProfileUrl + '/' + customerId);
|
|
|
|
try {
|
|
|
|
var response = await http.put(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
|
|
|
|
userName = _response['username'];
|
|
|
|
phoneNumber = _response['phone'];
|
|
|
|
email = _response['emails'][0]['email'];
|
|
|
|
emergencyContactNumber1 = _response['emergencyContacts'][0]['contactNumber'];
|
|
|
|
emergencyContactNumber2 = _response['emergencyContacts'][1]['contactNumber'];
|
|
|
|
emergencyRelation1 = _response['emergencyContacts'][0]['relationship'];
|
|
|
|
emergencyRelation2 = _response['emergencyContacts'][1]['relationship'];
|
|
|
|
emergencyRelationName1 = _response['emergencyContacts'][0]['name'];
|
|
|
|
emergencyRelationName2 = _response['emergencyContacts'][1]['name'];
|
|
|
|
bloodGroup = _response['bloodGroup'];
|
|
|
|
age = _response['age'].toString();
|
|
|
|
|
|
|
|
await saveData('phone', _response['phone'], 'STRING');
|
|
|
|
await saveData('email', _response['emails'][0]['email'], 'STRING');
|
|
|
|
await saveData('username', _response['username'], 'STRING');
|
|
|
|
await saveData('age', _response['age'].toString(), 'STRING');
|
|
|
|
|
|
|
|
await saveData('emergencyContactNumber1', _response['emergencyContacts'][0]['contactNumber'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyContactNumber2',_response['emergencyContacts'][1]['contactNumber'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelation1', _response['emergencyContacts'][0]['relationship'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelation2', _response['emergencyContacts'][1]['relationship'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelationName1', _response['emergencyContacts'][0]['name'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelationName2', _response['emergencyContacts'][1]['name'].toString(), 'STRING');
|
|
|
|
await saveData('bloodGroup', _response['bloodGroup'].toString(), 'STRING');
|
|
|
|
await saveData('bloodGroupPicture', _response['blood_Group_picture'].toString(), 'STRING');
|
|
|
|
await loadDataFromMemory();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> updateLocation(payload) async {
|
|
|
|
var uri = Uri.parse(updateLocationUrl + '/' + customerId);
|
|
|
|
try {
|
|
|
|
var response = await http.put(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
|
|
|
|
userAddress = _response['user']['profile']['address1'];
|
|
|
|
detailedAddress = _response['user']['profile']['address2'];
|
|
|
|
userLatitude = _response['user']['latitude'];
|
|
|
|
userLongitude =_response['user']['longitude'];
|
|
|
|
|
|
|
|
await saveData('user_address', _response['user']['profile']['address1'], 'STRING');
|
|
|
|
await saveData('detailedAddress', _response['user']['profile']['address2'], 'STRING');
|
|
|
|
if(_response['user']['latitude']==0){
|
|
|
|
_response['user']['latitude']=0.0;
|
|
|
|
}
|
|
|
|
if(_response['user']['longitude']==0){
|
|
|
|
_response['user']['longitude']=0.0;
|
|
|
|
}
|
|
|
|
await saveData('latitude', _response['user']['latitude'], 'DOUBLE');
|
|
|
|
await saveData('longitude', _response['user']['longitude'], 'DOUBLE');
|
|
|
|
await loadDataFromMemory();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> updatePin(payload) async {
|
|
|
|
var uri = Uri.parse(updatePinUrl + '/' + customerId);
|
|
|
|
try {
|
|
|
|
var response = await http.put(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getBmiHistory() async {
|
|
|
|
var uri = Uri.parse(getBmiHistoryUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getBPHistory() async {
|
|
|
|
var uri = Uri.parse(getBpHistoryUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getSugarHistory() async {
|
|
|
|
var uri = Uri.parse(getSugarHistoryUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static Future upload() async{
|
|
|
|
final uri = Uri.parse('https://myendpoint.com');
|
|
|
|
var request = new http.MultipartRequest('POST', uri);
|
|
|
|
final httpImage = http.MultipartFile.fromBytes('files.myimage', bytes,
|
|
|
|
contentType: MediaType.parse(mimeType), filename: 'myImage.png');
|
|
|
|
request.files.add(httpImage);
|
|
|
|
final response = await request.send();
|
|
|
|
}*/
|
|
|
|
|
|
|
|
static Future<http.StreamedResponse> uploadImageHTTP(file) async {
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(uploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> uploadImageHTTPNew(file) async {
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(uploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
static Future<String> uploadBloodGroupImage(file) async {
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(uploadBloodGroupPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> uploadImageHTTPForPrescriptions(file) async {
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(prescriptionUploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*upload and update findings*/
|
|
|
|
|
|
|
|
static Future<String> uploadFindingsGallery(file) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> uploadFindingsCamera(file) async {
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addFindingsGallery(file,pictureId) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'PUT', Uri.parse(addFindingsUrl + '/' + customerId+"/"+pictureId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addFindingsCamera(file,pictureId) async {
|
|
|
|
var request = http.MultipartRequest('PUT', Uri.parse(addFindingsUrl + '/' + customerId+"/"+pictureId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updateFindingsGallery(file,var recordId) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updateFindingsCamera(file,var recordId) async {
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*End*/
|
|
|
|
|
|
|
|
|
|
|
|
/*upload and update Reports*/
|
|
|
|
|
|
|
|
static Future<String> uploadReportsGallery(file) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(reportsUploadPicUrl + '/' + customerId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> uploadReportsCamera(file) async {
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(reportsUploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addReportsGallery(file,pictureId) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'PUT', Uri.parse(addReportsUrl + '/' + customerId+"/"+pictureId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addReportsCamera(file,pictureId) async {
|
|
|
|
var request = http.MultipartRequest('PUT', Uri.parse(addReportsUrl + '/' + customerId+"/"+pictureId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updateReportsGallery(file,var recordId) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(updateReportsUploadPicUrl + '/' + customerId+'/'+recordId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updateReportsCamera(file,var recordId) async {
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(updateReportsUploadPicUrl + '/' + customerId+'/'+recordId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*End*/
|
|
|
|
|
|
|
|
|
|
|
|
/*upload and update Prescriptions*/
|
|
|
|
|
|
|
|
static Future<String> uploadPrescriptionsGallery(file) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(prescriptionUploadPicUrl + '/' + customerId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> uploadPrescriptionsCamera(file) async {
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(prescriptionUploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addPrescriptionsGallery(file,pictureId) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'PUT', Uri.parse(addPrescriptionsUrl + '/' + customerId+"/"+pictureId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addPrescriptionsCamera(file,pictureId) async {
|
|
|
|
var request = http.MultipartRequest('PUT', Uri.parse(addPrescriptionsUrl + '/' + customerId+"/"+pictureId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updatePrescriptionsGallery(file,var recordId) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(updatePrescriptionPicUrl + '/' + customerId+'/'+recordId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updatePrescriptionsCamera(file,var recordId) async {
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(updatePrescriptionPicUrl + '/' + customerId+'/'+recordId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*End*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Future<String> uploadImageForReports(file) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(reportsUploadPicUrl + '/' + customerId));
|
|
|
|
if (file.length > 0) {
|
|
|
|
for (var i = 0; i < file.length; i++) {
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
|
|
|
|
}}
|
|
|
|
// request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<String> uploadImageForFindingsCamera(file) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<String> uploadVideoInReportMySelf(file) async {
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(reportMySelfVideoUploadUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('video', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<String> uploadReportMyselfPicture(file) async {
|
|
|
|
|
|
|
|
var request = http.MultipartRequest('POST', Uri.parse(uploadReportMyselfPictureUrl + '/' + customerId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllpharmacies() async {
|
|
|
|
var uri = Uri.parse(getAllpharmaciesDataUrl);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllQuotationRequests() async {
|
|
|
|
var uri = Uri.parse(getAllQuotationRequestsUrl+'/'+customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> addMedicineTimings(payload) async {
|
|
|
|
var uri = Uri.parse(addMedicineTimingsUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> updateMedicineTimings(payload) async {
|
|
|
|
var uri = Uri.parse(updateMedicineTimingsUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getMedicineTimings() async {
|
|
|
|
var uri = Uri.parse(getMedicineTimingsUrl + '/' + customerId);
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> getQuotation(payload) async {
|
|
|
|
var uri = Uri.parse(getQuotationUrl + '/' + customerId);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> addPrescription(payload) async {
|
|
|
|
var uri = Uri.parse(addPrescriptionUrl + '/' + customerId);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<bool> addRecords(payload) async {
|
|
|
|
var uri = Uri.parse(addRecordsUrl + '/' + customerId);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> updateRecord(payload,recordId) async {
|
|
|
|
var uri = Uri.parse(updateRecordsUrl + '/' + recordId);
|
|
|
|
var response = await http.put(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.put(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllPrescriptions() async {
|
|
|
|
var uri = Uri.parse(getAllPrescriptionsDataUrl + '/' + customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<String> getAllRecords() async {
|
|
|
|
var uri = Uri.parse(getRecordsDataUrl + '/' + customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<bool> deleteRecord(recordId) async {
|
|
|
|
var uri = Uri.parse(deleteRecordUrl + '/' + recordId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<String> deleteFindings(fileName,findingsId) async {
|
|
|
|
var uri = Uri.parse(deleteFindingsUrl + '/' + customerId+'/'+findingsId+'/'+fileName);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> deletePrescriptions(fileName,prescriptionId) async {
|
|
|
|
var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+prescriptionId+'/'+fileName);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> deleteReports(fileName,reportsId) async {
|
|
|
|
var uri = Uri.parse(deleteReportsUrl + '/' + customerId+'/'+reportsId+'/'+fileName);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static Future<String> deleteFindings(fileName) async {
|
|
|
|
var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+fileName);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
static Future<bool> deleteRecords(payload, recordId) async {
|
|
|
|
var uri = Uri.parse(deleteRecordsUrl + '/' + customerId+'/'+recordId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.post(uri, body: json.encode(payload),headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> deleteRecordsNew(payload, recordId) async {
|
|
|
|
var uri = Uri.parse(deleteRecordsUrl + '/' + customerId+'/'+recordId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.post(uri, body: json.encode(payload),headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> deleteBMIDetails(bmiId) async {
|
|
|
|
var uri = Uri.parse(deleteBMIDetailsUrl + '/' + customerId+'/'+ bmiId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> deleteBPDetails(bmiId) async {
|
|
|
|
var uri = Uri.parse(deleteBPDetailsUrl + '/' + customerId+'/'+ bmiId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> deleteSugarDetails(bmiId) async {
|
|
|
|
var uri = Uri.parse(deleteSugarDetailsUrl + '/' + customerId+'/'+ bmiId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.delete(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<bool> addReportMySelfProblem(payload) async {
|
|
|
|
var uri = Uri.parse(addReportMySelfProblemUrl + '/' + customerId);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllReportProblemDetalis() async {
|
|
|
|
var uri = Uri.parse(getAllReportProblemDetalisUrl+'/'+customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> deleteReportMySelfProblem(problemId) async {
|
|
|
|
var uri = Uri.parse(deleteReportMySelfProblemUrl + '/' +problemId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
var response = await http.put (uri, headers: await buildPutRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.put(uri, headers: await buildPutRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllConnectedDoctors() async {
|
|
|
|
var uri = Uri.parse(getAllConnectedDoctorsDataUrl + '/' + customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> addDoctor(payload) async {
|
|
|
|
var uri = Uri.parse(addDoctorUrl + '/' + customerId);
|
|
|
|
var response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getDynamicCode() async {
|
|
|
|
var uri = Uri.parse(getDynamicCodeDataUrl + '/' + customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*Apis ends here*/
|
|
|
|
|
|
|
|
//save data local
|
|
|
|
static Future<void> saveAvailableReportAndLocationsInMemory(
|
|
|
|
dynamic input) async {
|
|
|
|
// save login name information
|
|
|
|
await saveData('username', input['simplydata']['username'], 'STRING');
|
|
|
|
await saveData(
|
|
|
|
'access_token', input['simplydata']['access_token'], 'STRING');
|
|
|
|
await saveData('phone', input['simplydata']['phone'], 'STRING');
|
|
|
|
await saveData('email', input['simplydata']['email'][0]['email'], 'STRING');
|
|
|
|
await saveData('customerId', input['simplydata']['customerId'], 'STRING');
|
|
|
|
await saveData('profile', input['simplydata']['picture'], 'STRING');
|
|
|
|
await saveData('user_address', input['simplydata']['address1'], 'STRING');
|
|
|
|
await saveData('detailedAddress', input['simplydata']['address2'], 'STRING');
|
|
|
|
if(input['simplydata']['latitude']==0){
|
|
|
|
input['simplydata']['latitude']=0.0;
|
|
|
|
}
|
|
|
|
if(input['simplydata']['longitude']==0){
|
|
|
|
input['simplydata']['longitude']=0.0;
|
|
|
|
}
|
|
|
|
await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE');
|
|
|
|
await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE');
|
|
|
|
await saveData('fcmId', input['simplydata']['fcmId'], 'STRING');
|
|
|
|
await saveData('age', input['simplydata']['age'], 'STRING');
|
|
|
|
await saveData('gender', input['simplydata']['gender'], 'STRING');
|
|
|
|
await saveData('qrCode', input['simplydata']['qrCode'], 'STRING');
|
|
|
|
|
|
|
|
if(input['simplydata']['emergencyContacts'].length!=0){
|
|
|
|
await saveData('emergencyContactNumber1', input['simplydata']['emergencyContacts'][0]['contactNumber'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyContactNumber2',input['simplydata']['emergencyContacts'][1]['contactNumber'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelation1', input['simplydata']['emergencyContacts'][0]['relationship'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelation2', input['simplydata']['emergencyContacts'][1]['relationship'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelationName1', input['simplydata']['emergencyContacts'][0]['name'].toString(), 'STRING');
|
|
|
|
await saveData('emergencyRelationName2', input['simplydata']['emergencyContacts'][1]['name'].toString(), 'STRING');
|
|
|
|
}
|
|
|
|
await saveData('bloodGroup', input['simplydata']['bloodGroup'].toString(), 'STRING');
|
|
|
|
await saveData('bloodGroupPicture', input['simplydata']['blood_Group_picture'].toString(), 'STRING');
|
|
|
|
//await saveData('age', input['simplydata']['age'], 'STRING');
|
|
|
|
//latitude,longitude
|
|
|
|
await loadDataFromMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static Future<void> saveProfile(dynamic image) async {
|
|
|
|
// save login name information
|
|
|
|
await saveData('profile', image.toString(), 'STRING');
|
|
|
|
//await loadDataFromMemory();
|
|
|
|
}*/
|
|
|
|
|
|
|
|
static Uint8List convertBase64Image(String base64String) {
|
|
|
|
return Base64Decoder().convert(base64String.split(',').last);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<void> loadDataFromMemory() async {
|
|
|
|
userName = await getData('username', 'STRING');
|
|
|
|
accessToken = await getData('access_token', 'STRING');
|
|
|
|
email = await getData('email', 'STRING');
|
|
|
|
userAddress = await getData('user_address', 'STRING');
|
|
|
|
detailedAddress= await getData('detailedAddress', 'STRING');
|
|
|
|
phoneNumber = await getData('phone', 'STRING');
|
|
|
|
customerId = await getData('customerId', 'STRING');
|
|
|
|
userLatitude = await getData('latitude', 'DOUBLE');
|
|
|
|
userLongitude = await getData('longitude', 'DOUBLE');
|
|
|
|
profilePictureUrl = await getData('profile', 'STRING');
|
|
|
|
fcmId = await getData('fcmId', 'STRING');
|
|
|
|
age = await getData('age', 'STRING');
|
|
|
|
gender = await getData('gender', 'STRING');
|
|
|
|
originalQrCode = await getData('qrCode', 'STRING');
|
|
|
|
emergencyContactNumber1 =await getData('emergencyContactNumber1', 'STRING');
|
|
|
|
emergencyContactNumber2 = await getData('emergencyContactNumber2', 'STRING');
|
|
|
|
emergencyRelation1 = await getData('emergencyRelation1', 'STRING');
|
|
|
|
emergencyRelation2 = await getData('emergencyRelation2', 'STRING');
|
|
|
|
emergencyRelationName1 = await getData('emergencyRelationName1', 'STRING');
|
|
|
|
emergencyRelationName2 =await getData('emergencyRelationName2', 'STRING');
|
|
|
|
bloodGroup = await getData('bloodGroup', 'STRING');
|
|
|
|
bloodGroupPictureUrl= await getData('bloodGroupPicture', 'STRING');
|
|
|
|
String dataUri = originalQrCode;
|
|
|
|
|
|
|
|
// Split the data URI at the comma to extract the Base64 part
|
|
|
|
List<String> parts = dataUri.split(",");
|
|
|
|
String? base64String = parts.length == 2 ? parts[1] : null;
|
|
|
|
|
|
|
|
if (base64String != null) {
|
|
|
|
qrCode=base64String;
|
|
|
|
} else {
|
|
|
|
print("Invalid data URI");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void longSuccessToast(String message) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: message,
|
|
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 16.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void longSuccessToast1(String message) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: message,
|
|
|
|
toastLength: Toast.LENGTH_LONG,
|
|
|
|
gravity: ToastGravity.CENTER,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 16.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void longFailedToast(String message) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: message,
|
|
|
|
toastLength: Toast.LENGTH_LONG,
|
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.red,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 16.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Widget noDataUI(String _tabName) {
|
|
|
|
_tabName = _tabName ?? '';
|
|
|
|
return Container(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Image(
|
|
|
|
image: AssetImage('images/no_data.png'),
|
|
|
|
width: 200,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
'There is no data to show you right now.',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.grey[600],
|
|
|
|
fontFamily: 'Swis2',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
_tabName,
|
|
|
|
style: TextStyle(fontSize: 15, fontFamily: 'Swis1'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static appBar(String title) {
|
|
|
|
title = title ?? '';
|
|
|
|
return AppBar(
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
title: Text(title),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*location*/
|
|
|
|
static checkGps() async {
|
|
|
|
servicestatus = await Geolocator.isLocationServiceEnabled();
|
|
|
|
if (servicestatus) {
|
|
|
|
permission = await Geolocator.checkPermission();
|
|
|
|
|
|
|
|
if (permission == LocationPermission.denied) {
|
|
|
|
permission = await Geolocator.requestPermission();
|
|
|
|
if (permission == LocationPermission.denied) {
|
|
|
|
print('Location permissions are denied');
|
|
|
|
} else if (permission == LocationPermission.deniedForever) {
|
|
|
|
print("'Location permissions are permanently denied");
|
|
|
|
} else {
|
|
|
|
haspermission = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
haspermission = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (haspermission) {
|
|
|
|
/*setState(() {
|
|
|
|
//refresh the UI
|
|
|
|
});*/
|
|
|
|
|
|
|
|
await getLocation();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print("GPS Service is not enabled, turn on GPS location");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static getLocation() async {
|
|
|
|
position = await Geolocator.getCurrentPosition(
|
|
|
|
desiredAccuracy: LocationAccuracy.high);
|
|
|
|
/*print(position.longitude); //Output: 80.24599079
|
|
|
|
print(position.latitude);*/ //Output: 29.6593457
|
|
|
|
|
|
|
|
long = await position.longitude.toString();
|
|
|
|
lat = await position.latitude.toString();
|
|
|
|
|
|
|
|
/*setState(() {
|
|
|
|
//refresh UI
|
|
|
|
});*/
|
|
|
|
|
|
|
|
LocationSettings locationSettings = LocationSettings(
|
|
|
|
accuracy: LocationAccuracy.high, //accuracy of the location data
|
|
|
|
distanceFilter: 100, //minimum distance (measured in meters) a
|
|
|
|
//device must move horizontally before an update event is generated;
|
|
|
|
);
|
|
|
|
|
|
|
|
StreamSubscription<Position> positionStream =
|
|
|
|
Geolocator.getPositionStream(locationSettings: locationSettings)
|
|
|
|
.listen((Position position) {
|
|
|
|
print(position.longitude); //Output: 80.24599079
|
|
|
|
print(position.latitude); //Output: 29.6593457
|
|
|
|
|
|
|
|
long = position.longitude.toString();
|
|
|
|
lat = position.latitude.toString();
|
|
|
|
|
|
|
|
/*setState(() {
|
|
|
|
//refresh UI on update
|
|
|
|
});*/
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|