toBytes method

Uint8List toBytes()

Converts a color to a byte list using BytesBuilder returning a 4-byte list.

Implementation

Uint8List toBytes() {
  final bb = BytesBuilder();
  final rgbColor = toRgbColor();

  bb.addByte(rgbColor.r.toInt());
  bb.addByte(rgbColor.g.toInt());
  bb.addByte(rgbColor.b.toInt());
  bb.addByte(255);

  return bb.toBytes();
}