mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 01:27:49 +08:00
17
lib/utils/color_utils.dart
Normal file
17
lib/utils/color_utils.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/rendering.dart' show Color;
|
||||
|
||||
abstract final class ColourUtils {
|
||||
static Color parseColor(String color) =>
|
||||
Color(int.parse('FF${color.substring(1)}', radix: 16));
|
||||
|
||||
static Color parseMedalColor(String color) => Color(
|
||||
int.parse('${color.substring(7)}${color.substring(1, 7)}', radix: 16),
|
||||
);
|
||||
|
||||
static Color index2Color(int index, Color color) => switch (index) {
|
||||
0 => const Color(0xFFfdad13),
|
||||
1 => const Color(0xFF8aace1),
|
||||
2 => const Color(0xFFdfa777),
|
||||
_ => color,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user