Browse Source

1、先截取usercode 哈希值的后十位进行生成随机颜色

bakamaka.guan 2 years ago
parent
commit
c57d94344f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      lib/components/white_board/color_util.dart

+ 1 - 1
lib/components/white_board/color_util.dart

@@ -6,7 +6,7 @@ import 'package:crypto/crypto.dart';
 class ColorUtil {
   static Color generateColor(String uuid) {
     final hash = sha256.convert(utf8.encode(uuid)).toString();
-    final intHash = int.parse(hash.substring(hash.length - 8), radix: 16);
+    final intHash = int.parse(hash.substring(hash.length - 10), radix: 16);
     final Random random = Random(intHash);
     final double r = random.nextInt(256).toDouble();
     final double g = random.nextInt(256).toDouble();