53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class GlobalFunction{
|
|
bool validateMobileNumber(String value) {
|
|
String patttern = r'(^(?:[+0]9)?[0-9]{10,15}$)';
|
|
RegExp regExp = new RegExp(patttern);
|
|
if (value.length < 8) {
|
|
return false;
|
|
} else if (!regExp.hasMatch(value)) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool validateEmail(String value) {
|
|
String pattern = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
|
RegExp regex = new RegExp(pattern);
|
|
if (!regex.hasMatch(value)) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
String removeDecimalZeroFormat(double v) {
|
|
NumberFormat formatter = NumberFormat();
|
|
formatter.minimumFractionDigits = 0;
|
|
formatter.maximumFractionDigits = 2;
|
|
return formatter.format(v);
|
|
}
|
|
|
|
String formatTime(int timeNum) {
|
|
return timeNum < 10 ? "0" + timeNum.toString() : timeNum.toString();
|
|
}
|
|
|
|
Future showProgressDialog(BuildContext context) {
|
|
return showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return WillPopScope(
|
|
onWillPop: () {
|
|
return Future.value(false);
|
|
},
|
|
child: Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
} |