Initial commit: family safety frontend project setup
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
class StringUtil {
|
||||
static bool isValidEmail(String email) {
|
||||
final regExp = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*\.(\w+)$');
|
||||
return regExp.hasMatch(email);
|
||||
}
|
||||
|
||||
static String truncate(String text, int maxLength) {
|
||||
if (text.length <= maxLength) return text;
|
||||
return '${text.substring(0, maxLength)}...';
|
||||
}
|
||||
|
||||
static String formatDateTime(String dateTime) {
|
||||
try {
|
||||
final date = DateTime.parse(dateTime);
|
||||
return '${date.day}/${date.month}/${date.year} '
|
||||
'${date.hour}:${date.minute.toString().padLeft(2, '0')}';
|
||||
} catch (e) {
|
||||
return dateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user