tryMoveLayerIndices method
Parses layer move metadata from the action payload.
Expected schema: {sourceLayerIndex: int, targetLayerIndex: int}.
Implementation
({int sourceLayerIndex, int targetLayerIndex})? tryMoveLayerIndices() {
final payload = this.payload;
if (payload == null) return null;
int? tryInt(Object? value) {
if (value is int) return value;
if (value is num) {
final asInt = value.toInt();
if (value == asInt) return asInt;
}
return null;
}
final source = tryInt(payload['sourceLayerIndex']);
final target = tryInt(payload['targetLayerIndex']);
if (source == null || target == null) return null;
return (sourceLayerIndex: source, targetLayerIndex: target);
}