StickerLayerData.fromMap constructor

StickerLayerData.fromMap(
  1. Layer layer,
  2. Map map,
  3. List<Uint8List> stickers
)

Implementation

factory StickerLayerData.fromMap(
  Layer layer,
  Map map,
  List<Uint8List> stickers,
) {
  int stickerPosition = map['listPosition'] ?? -1;
  Widget sticker = kDebugMode
      ? Text(
          'Sticker $stickerPosition not found',
          style: const TextStyle(color: Colors.red, fontSize: 24),
        )
      : const SizedBox.shrink();
  if (stickers.isNotEmpty && stickers.length > stickerPosition) {
    sticker = ConstrainedBox(
      constraints: const BoxConstraints(minWidth: 1, minHeight: 1),
      child: Image.memory(
        stickers[stickerPosition],
      ),
    );
  }

  return StickerLayerData(
    flipX: layer.flipX,
    flipY: layer.flipY,
    offset: layer.offset,
    rotation: layer.rotation,
    scale: layer.scale,
    sticker: sticker,
  );
}