quantize method Null safety

  1. @override
Future<QuantizerResult> quantize(
  1. Iterable<int> pixels,
  2. int maxColors
)
override

Implementation

@override
Future<QuantizerResult> quantize(Iterable<int> pixels, int maxColors) async {
  final countByColor = <int, int>{};
  for (final pixel in pixels) {
    final alpha = ColorUtils.alphaFromArgb(pixel);
    if (alpha < 255) {
      continue;
    }
    countByColor[pixel] = (countByColor[pixel] ?? 0) + 1;
  }
  return QuantizerResult(countByColor);
}