fromColor method

Future<void> fromColor(
  1. Color color
)

Creates a 1x1 solid color texture.

Implementation

Future<void> fromColor(ui.Color color) async {
  final bytes = Uint8List.fromList([
    (color.r * 255.0).round().clamp(0, 255),
    (color.g * 255.0).round().clamp(0, 255),
    (color.b * 255.0).round().clamp(0, 255),
    (color.a * 255.0).round().clamp(0, 255),
  ]);
  await fromBytes(bytes, 1, 1);
}