2024-08-30 00:31:43 +00:00
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
2022-11-30 00:56:14 +00:00
|
|
|
extension StringUtils on String {
|
|
|
|
String truncate({int length = 32}) {
|
2023-01-07 18:01:32 +00:00
|
|
|
if (this.length <= length) {
|
2022-11-30 00:56:14 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '${substring(0, length)}...';
|
|
|
|
}
|
2023-03-20 14:06:44 +00:00
|
|
|
|
2024-08-30 00:31:43 +00:00
|
|
|
String stripHyperlinks() => replaceAll(
|
|
|
|
RegExp(
|
2023-03-20 14:06:44 +00:00
|
|
|
r"(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?"),
|
2024-08-30 00:31:43 +00:00
|
|
|
"");
|
2022-11-30 00:56:14 +00:00
|
|
|
}
|
2024-08-30 00:31:43 +00:00
|
|
|
|
|
|
|
final decimalWithCommasFormat = NumberFormat("#,##0.###");
|