ColorsUtils.dart 421 B

123456789101112131415161718
  1. import 'dart:ui';
  2. class ColorsUtil {
  3. /// 十六进制颜色,
  4. /// hex, 十六进制值,例如:0xffffff,
  5. /// alpha, 透明度 [0.0,1.0]
  6. static Color hexColor(int hex,{double alpha = 1}){
  7. if (alpha < 0){
  8. alpha = 0;
  9. }else if (alpha > 1){
  10. alpha = 1;
  11. }
  12. return Color.fromRGBO((hex & 0xFF0000) >> 16 ,
  13. (hex & 0x00FF00) >> 8,
  14. (hex & 0x0000FF) >> 0,
  15. alpha);
  16. }
  17. }