JXColors.dart 839 B

12345678910111213141516171819202122232425262728293031
  1. import 'package:flutter/material.dart';
  2. /*
  3. 颜色统一处理
  4. * */
  5. class JXColors {
  6. // white
  7. static Color Color_FFFFFF = hexColor(0xFFFFFF);
  8. static Color Color_F0F0F0 = hexColor(0xF0F0F0);
  9. static Color Color_E6E6E6 = hexColor(0xE6E6E6);
  10. static Color Color_747A7E = hexColor(0x747A7E);
  11. // dark
  12. static Color Color_2E3032 = hexColor(0x2E3032);
  13. static Color Color_101E40 = hexColor(0x101E40);
  14. static Color Color_1F2529 = hexColor(0x1F2529);
  15. /// 十六进制颜色,
  16. /// hex, 十六进制值,例如:0xffffff,
  17. /// alpha, 透明度 [0.0,1.0]
  18. static Color hexColor(int hex,{double alpha = 1}){
  19. if (alpha < 0){
  20. alpha = 0;
  21. }else if (alpha > 1){
  22. alpha = 1;
  23. }
  24. return Color.fromRGBO((hex & 0xFF0000) >> 16 ,
  25. (hex & 0x00FF00) >> 8,
  26. (hex & 0x0000FF) >> 0,
  27. alpha);
  28. }
  29. }