copyWith method

ConditionalOn copyWith({
  1. String? field,
  2. List? values,
  3. String? conditionalValueKey,
  4. Regex? regex,
})

✅ Add copyWith method

Implementation

ConditionalOn copyWith({
  String? field,
  List<dynamic>? values,
  String? conditionalValueKey,
  Regex? regex,
}) {
  return ConditionalOn(
    field: field ?? this.field,
    values: values ?? List<dynamic>.from(this.values), // Clone the list
    conditionalValueKey: conditionalValueKey ?? this.conditionalValueKey,
    regex: regex ?? this.regex?.copyWith(), // Use copyWith for nested objects
  );
}