chartPalette function

List<String>? chartPalette(
  1. String accent
)

chartPaletteOf for a color written #AARRGGBB (or #RRGGBB), as #AARRGGBB texts; null for a text that is no such color.

Implementation

List<String>? chartPalette(String accent) {
  final m = RegExp(r'^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$').firstMatch(accent);
  if (m == null) return null;
  final hex = m[1]!;
  final argb = int.parse(hex.length == 6 ? 'FF$hex' : hex, radix: 16);
  return [
    accent.length == 9 ? accent.toUpperCase() : '#FF${hex.toUpperCase()}',
    for (final c in chartPaletteOf(argb).skip(1)) '#${c.toRadixString(16).padLeft(8, '0').toUpperCase()}',
  ];
}