dragSticker method

void dragSticker({
  1. required StickerAsset asset,
  2. required DragUpdate update,
})

sticker dragged

Implementation

void dragSticker({
  required StickerAsset asset,
  required DragUpdate update,
}) {
  Future.delayed(const Duration(milliseconds: 16), () {
    final assets = List.of(value.assets);
    final index = assets.indexWhere((element) => element.id == asset.id);
    if (index.isNegative) return;

    final sticker = assets.removeAt(index);
    assets.add(
      sticker.copyWith(
        angle: update.angle,
        scale: update.scale,
        position: StickerPosition(
          dx: update.position.dx,
          dy: update.position.dy,
        ),
        size: StickerSize(
          width: update.size.width,
          height: update.size.height,
        ),
        constraint: StickerConstraint(
          width: update.constraints.width,
          height: update.constraints.height,
        ),
      ),
    );
    value = value.copyWith(assets: assets, selectedAssetId: asset.id);
  });
}