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 _kTapIndex:
      return 'SemanticsAction.tap';
    case _kLongPressIndex:
      return 'SemanticsAction.longPress';
    case _kScrollLeftIndex:
      return 'SemanticsAction.scrollLeft';
    case _kScrollRightIndex:
      return 'SemanticsAction.scrollRight';
    case _kScrollUpIndex:
      return 'SemanticsAction.scrollUp';
    case _kScrollDownIndex:
      return 'SemanticsAction.scrollDown';
    case _kIncreaseIndex:
      return 'SemanticsAction.increase';
    case _kDecreaseIndex:
      return 'SemanticsAction.decrease';
    case _kShowOnScreenIndex:
      return 'SemanticsAction.showOnScreen';
    case _kMoveCursorForwardByCharacterIndex:
      return 'SemanticsAction.moveCursorForwardByCharacter';
    case _kMoveCursorBackwardByCharacterIndex:
      return 'SemanticsAction.moveCursorBackwardByCharacter';
    case _kSetSelectionIndex:
      return 'SemanticsAction.setSelection';
    case _kCopyIndex:
      return 'SemanticsAction.copy';
    case _kCutIndex:
      return 'SemanticsAction.cut';
    case _kPasteIndex:
      return 'SemanticsAction.paste';
    case _kDidGainAccessibilityFocusIndex:
      return 'SemanticsAction.didGainAccessibilityFocus';
    case _kDidLoseAccessibilityFocusIndex:
      return 'SemanticsAction.didLoseAccessibilityFocus';
    case _kCustomActionIndex:
      return 'SemanticsAction.customAction';
    case _kDismissIndex:
      return 'SemanticsAction.dismiss';
    case _kMoveCursorForwardByWordIndex:
      return 'SemanticsAction.moveCursorForwardByWord';
    case _kMoveCursorBackwardByWordIndex:
      return 'SemanticsAction.moveCursorBackwardByWord';
    case _kSetTextIndex:
      return 'SemanticsAction.setText';
  }
  assert(false, 'Unhandled index: $index (0x${index.toRadixString(8).padLeft(4, "0")})');
  return '';
}