getProperties method

  1. @override
Map<String, dynamic> getProperties({
  1. Element? ancestor,
})
override

Implementation

@override
Map<String, dynamic> getProperties({Element? ancestor}) {
  Map<String, dynamic> properties = super.getProperties(ancestor: ancestor);

  String? associatedText = '';
  bool? isChecked;
  String? className;
  if (element.widget is CheckboxListTile) {
    CheckboxListTile checkboxTile = element.widget as CheckboxListTile;
    className = RanorexSupportedClassName.checkboxListTile;
    if (checkboxTile.title is Text) {
      associatedText = (checkboxTile.title as Text).data ?? '';
    }
    isChecked = checkboxTile.value;
  } else {
    className = RanorexSupportedClassName.checkbox;
    Checkbox checkboxWidget = element.widget as Checkbox;
    isChecked = checkboxWidget.value;
    associatedText = findAssociatedText(element);
  }

  String checkState = isChecked == null
      ? 'Indeterminate'
      : isChecked
          ? 'Checked'
          : 'Unchecked';

  properties[WidgetProperty.className.name] = className;
  properties[WidgetProperty.checked.name] = isChecked ?? false;
  properties[WidgetProperty.checkState.name] = checkState;
  properties[WidgetProperty.text.name] = associatedText ?? '';
  properties[WidgetProperty.accessibilityLabel.name] =
      element.findAncestorWidgetOfExactType<Semantics>()?.properties.label ??
          '';
  return properties;
}