PaintLayerData.fromMap constructor

PaintLayerData.fromMap(
  1. Layer layer,
  2. Map<String, dynamic> map
)

Factory constructor for creating a PaintLayerData instance from a Layer and a map.

Implementation

factory PaintLayerData.fromMap(Layer layer, Map<String, dynamic> map) {
  /// Constructs and returns a PaintLayerData instance with properties
  /// derived from the layer and map.
  return PaintLayerData(
    flipX: layer.flipX,
    flipY: layer.flipY,
    enableInteraction: layer.enableInteraction,
    offset: layer.offset,
    rotation: layer.rotation,
    scale: layer.scale,
    opacity: safeParseDouble(map['opacity'], fallback: 1.0),
    rawSize: Size(
      safeParseDouble(map['rawSize']?['w'], fallback: 0),
      safeParseDouble(map['rawSize']?['h'], fallback: 0),
    ),
    item: PaintedModel.fromMap(map['item'] ?? {}),
  );
}