2
0
mirror of https://gitlab.com/famedly/fluffychat.git synced 2024-12-03 17:59:45 +01:00
fluffychat/lib/utils/string_color.dart
2020-06-25 09:15:53 +02:00

22 lines
517 B
Dart

import 'package:flutter/material.dart';
extension StringColor on String {
Color get color {
var number = 0.0;
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
}
number = (number % 10) * 25.5;
return HSLColor.fromAHSL(1, number, 1, 0.35).toColor();
}
Color get lightColor {
var number = 0.0;
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
}
number = (number % 10) * 25.5;
return HSLColor.fromAHSL(1, number, 1, 0.66).toColor();
}
}