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));
  }
}