toString method Null safety

  1. @override
String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Implementation

@override
String toString() {
  switch (index) {
    case _kHasCheckedStateIndex:
      return 'SemanticsFlag.hasCheckedState';
    case _kIsCheckedIndex:
      return 'SemanticsFlag.isChecked';
    case _kIsSelectedIndex:
      return 'SemanticsFlag.isSelected';
    case _kIsButtonIndex:
      return 'SemanticsFlag.isButton';
    case _kIsTextFieldIndex:
      return 'SemanticsFlag.isTextField';
    case _kIsFocusedIndex:
      return 'SemanticsFlag.isFocused';
    case _kHasEnabledStateIndex:
      return 'SemanticsFlag.hasEnabledState';
    case _kIsEnabledIndex:
      return 'SemanticsFlag.isEnabled';
    case _kIsInMutuallyExclusiveGroupIndex:
      return 'SemanticsFlag.isInMutuallyExclusiveGroup';
    case _kIsHeaderIndex:
      return 'SemanticsFlag.isHeader';
    case _kIsObscuredIndex:
      return 'SemanticsFlag.isObscured';
    case _kScopesRouteIndex:
      return 'SemanticsFlag.scopesRoute';
    case _kNamesRouteIndex:
      return 'SemanticsFlag.namesRoute';
    case _kIsHiddenIndex:
      return 'SemanticsFlag.isHidden';
    case _kIsImageIndex:
      return 'SemanticsFlag.isImage';
    case _kIsLiveRegionIndex:
      return 'SemanticsFlag.isLiveRegion';
    case _kHasToggledStateIndex:
      return 'SemanticsFlag.hasToggledState';
    case _kIsToggledIndex:
      return 'SemanticsFlag.isToggled';
    case _kHasImplicitScrollingIndex:
      return 'SemanticsFlag.hasImplicitScrolling';
    case _kIsMultilineIndex:
      return 'SemanticsFlag.isMultiline';
    case _kIsReadOnlyIndex:
      return 'SemanticsFlag.isReadOnly';
    case _kIsFocusableIndex:
      return 'SemanticsFlag.isFocusable';
    case _kIsLinkIndex:
      return 'SemanticsFlag.isLink';
    case _kIsSliderIndex:
      return 'SemanticsFlag.isSlider';
    case _kIsKeyboardKeyIndex:
      return 'SemanticsFlag.isKeyboardKey';
  }
  assert(false, 'Unhandled index: $index (0x${index.toRadixString(8).padLeft(4, "0")})');
  return '';
}