Files
Remever/lib/components/extensions/string.dart
2025-03-03 20:59:42 +03:00

32 lines
669 B
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Flutter imports:
import 'package:flutter/material.dart' show Color;
///
/// Расширение для работы со строками
///
extension MString on String {
///
/// Слово с заглавной буквы
///
String capitalyze() {
final String str = toLowerCase();
final String first = str.substring(0, 1);
return '${first.toUpperCase()}${str.substring(1)}';
}
///
/// Парсинг hex string в color
///
Color get toColor {
String res = replaceFirst('#', '');
return Color(
int.parse(
res.length == 8 ? res : (res.length == 6 ? 'FF$res' : res),
radix: 16,
),
);
}
}