2020-01-18 13:22:22 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
extension StringColor on String {
|
|
|
|
Color get color {
|
2020-06-25 09:15:53 +02:00
|
|
|
var number = 0.0;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
number += codeUnitAt(i);
|
|
|
|
}
|
2021-07-31 20:12:18 +02:00
|
|
|
number = (number % 12) * 25.5;
|
2020-06-25 09:15:53 +02:00
|
|
|
return HSLColor.fromAHSL(1, number, 1, 0.35).toColor();
|
|
|
|
}
|
|
|
|
|
2021-01-16 21:50:01 +01:00
|
|
|
Color get darkColor {
|
|
|
|
var number = 0.0;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
number += codeUnitAt(i);
|
|
|
|
}
|
2021-07-31 20:12:18 +02:00
|
|
|
number = (number % 12) * 25.5;
|
2021-01-16 21:50:01 +01:00
|
|
|
return HSLColor.fromAHSL(1, number, 1, 0.2).toColor();
|
|
|
|
}
|
|
|
|
|
2020-06-25 09:15:53 +02:00
|
|
|
Color get lightColor {
|
2020-05-13 15:58:59 +02:00
|
|
|
var number = 0.0;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
number += codeUnitAt(i);
|
2020-01-18 13:22:22 +01:00
|
|
|
}
|
2021-07-31 20:12:18 +02:00
|
|
|
number = (number % 12) * 25.5;
|
2022-08-05 16:12:00 +02:00
|
|
|
return HSLColor.fromAHSL(1, number, 1, 0.40).toColor();
|
2020-01-18 13:22:22 +01:00
|
|
|
}
|
|
|
|
}
|