This commit is contained in:
cxc
2022-06-27 09:51:30 +08:00
commit 8cb96b4c5e
101 changed files with 11110 additions and 0 deletions

25
lib/utils/color.dart Normal file
View File

@ -0,0 +1,25 @@
import 'dart:ui';
import 'package:flutter/material.dart';
//调用的时候需要把hex改一下比如#223344 needs change to 0xFF223344
//即把#换成0xFF即可
MaterialColor createMaterialColor(Color color) {
List strengths = <double>[.05];
Map swatch = <int, Color>{};
final int r = color.red, g = color.green, b = color.blue;
for (int i = 1; i < 10; i++) {
strengths.add(0.1 * i);
}
strengths.forEach((strength) {
final double ds = 0.5 - strength;
swatch[(strength * 1000).round()] = Color.fromRGBO(
r + ((ds < 0 ? r : (255 - r)) * ds).round(),
g + ((ds < 0 ? g : (255 - g)) * ds).round(),
b + ((ds < 0 ? b : (255 - b)) * ds).round(),
1,
);
});
return MaterialColor(color.value, swatch);
}