copyWith method

UiElement copyWith({
  1. String? elementId,
  2. String? testId,
  3. String? type,
  4. String? role,
  5. String? label,
  6. String? text,
  7. String? hint,
  8. List<String>? options,
  9. ElementLocator? suggestedLocator,
  10. bool clearSuggestedLocator = false,
  11. String? locatorWarning,
  12. bool clearLocatorWarning = false,
  13. UiElementState? state,
  14. UiBounds? bounds,
  15. List<String>? actions,
  16. List<UiElement>? children,
  17. Map<String, Object?>? metadata,
})

Copy with selected fields replaced.

Pass clearSuggestedLocator / clearLocatorWarning to null those fields.

Implementation

UiElement copyWith({
  String? elementId,
  String? testId,
  String? type,
  String? role,
  String? label,
  String? text,
  String? hint,
  List<String>? options,
  ElementLocator? suggestedLocator,
  bool clearSuggestedLocator = false,
  String? locatorWarning,
  bool clearLocatorWarning = false,
  UiElementState? state,
  UiBounds? bounds,
  List<String>? actions,
  List<UiElement>? children,
  Map<String, Object?>? metadata,
}) {
  return UiElement(
    elementId: elementId ?? this.elementId,
    testId: testId ?? this.testId,
    type: type ?? this.type,
    role: role ?? this.role,
    label: label ?? this.label,
    text: text ?? this.text,
    hint: hint ?? this.hint,
    options: options ?? this.options,
    suggestedLocator: clearSuggestedLocator
        ? suggestedLocator
        : (suggestedLocator ?? this.suggestedLocator),
    locatorWarning: clearLocatorWarning
        ? locatorWarning
        : (locatorWarning ?? this.locatorWarning),
    state: state ?? this.state,
    bounds: bounds ?? this.bounds,
    actions: actions ?? this.actions,
    children: children ?? this.children,
    metadata: metadata ?? this.metadata,
  );
}