You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/uitl/utils.dart

41 lines
1.1 KiB
Dart

import 'package:connectivity/connectivity.dart';
import 'app_shared_preferences.dart';
import 'app_toast.dart';
AppSharedPreferences sharedPref = new AppSharedPreferences();
class Utils {
///show custom Error Toast
/// [message] to show for user
static showErrorToast([String message]) {
String localMsg = generateContactAdminMessage();
if (message != null) {
localMsg = message.toString();
}
AppToast.showErrorToast(message: localMsg);
}
/// Check The Internet Connection
static Future<bool> checkConnection() async {
ConnectivityResult connectivityResult =
await (Connectivity().checkConnectivity());
if ((connectivityResult == ConnectivityResult.mobile) ||
(connectivityResult == ConnectivityResult.wifi)) {
return true;
} else {
return false;
}
}
/// generate Contact Admin Message
static generateContactAdminMessage([err]) {
String localMsg = 'Something wrong happened, please contact the admin';
if (err != null) {
localMsg = localMsg + '\n \n' + err.toString();
}
return localMsg;
}
}