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.
tangheem/lib/extensions/string_extensions.dart

15 lines
548 B
Dart

import 'package:intl/intl.dart';
extension EmailValidator on String {
bool isValidEmail() {
return RegExp(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,}))$').hasMatch(this);
}
String toFormattedDate() {
DateFormat inputFormat = DateFormat('yyyy-mm-ddThh:mm:ss');
DateTime inputDate = inputFormat.parse(this);
DateFormat outputFormat = DateFormat('dd/MM/yyyy hh:mm:a');
return outputFormat.format(inputDate);
}
}