This commit is contained in:
unknown
2021-08-30 22:38:58 +02:00
parent 9544d89993
commit 46fa86f989
152 changed files with 4074 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
class ColorUtils {
static Color stringToColor(String str) {
int hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.codeUnitAt(i) + ((hash << 5) - hash);
}
return HSLColor.fromAHSL(1, hash % 360, .8, .75).toColor();
}
static Color foregroundColor(Color color) => color.computeLuminance() >= .5 ? Colors.black : Colors.white;
}