Blame view

lib/utils/color_util.dart 458 Bytes
e5c9e98f   liangchengyou   feat:首页模块颜色
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  import 'dart:ui';
  
  class HexColor extends Color {
    static int _getColorFromHex(String hexColor) {
      if (hexColor.isEmpty) {
        hexColor = '#FFC0C3E7';
      }
      hexColor = hexColor.toUpperCase().replaceAll("#", "");
      hexColor = hexColor.replaceAll('0X', '');
      if (hexColor.length == 6) {
        hexColor = "FF$hexColor";
      }
      return int.parse(hexColor, radix: 16);
    }
  
    HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
  }