| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import 'dart:ui';
- extension HexColor on String {
- Color get color => toColor();
- Color toColor() {
- String hex = replaceAll('#', '');
- if (hex.length == 6) {
- hex = 'FF$hex';
- }
- return Color(int.parse(hex, radix: 16));
- }
- }
- extension DoubleExtension on double {
- String toFormattedString(int fractionDigits) {
- if (this == toInt()) {
- return toInt().toString();
- } else {
- return toStringAsFixed(fractionDigits);
- }
- }
- double toFormattedDouble(int fractionDigits) {
- return double.parse(toStringAsFixed(fractionDigits));
- }
- }
- extension TrimAllExtension on String {
- String trimAll() {
- return replaceAll(RegExp(r'\s+'), '');
- }
- String trimAndReduceSpaces() {
- return trim().replaceAll(RegExp(r'\s+'), ' ');
- }
- }
|