toJson method

  1. @override
Map<String, dynamic> toJson()
override

Abstract function that concrete classes must implement. This must encode the internal data model to a JSON compatible representation.

While not required, it is suggested to call removeNull before returning.

Implementation

@override
Map<String, dynamic> toJson() {
  final sortKeyEncoded = _JsonSemanticsBuilder._encodeSortKey(sortKey);

  return JsonClass.removeNull({
    'attributedDecreasedValue': attributedDecreasedValue,
    'attributedHint': attributedHint,
    'attributedIncreasedValue': attributedIncreasedValue,
    'attributedLabel': attributedLabel,
    'attributedValue': attributedValue,
    'blockUserActions': false == blockUserActions ? null : blockUserActions,
    'button': button,
    'checked': checked,
    'container': false == container ? null : container,
    'currentValueLength': currentValueLength,
    'customSemanticsActions': customSemanticsActions,
    'decreasedValue': decreasedValue,
    'enabled': enabled,
    'excludeSemantics': false == excludeSemantics ? null : excludeSemantics,
    'expanded': expanded,
    'explicitChildNodes':
        false == explicitChildNodes ? null : explicitChildNodes,
    'focusable': focusable,
    'focused': focused,
    'header': header,
    'hidden': hidden,
    'hint': hint,
    'identifier': identifier,
    'image': image,
    'inMutuallyExclusiveGroup': inMutuallyExclusiveGroup,
    'increasedValue': increasedValue,
    'keyboardKey': keyboardKey,
    'label': label,
    'link': link,
    'liveRegion': liveRegion,
    'maxValueLength': maxValueLength,
    'mixed': mixed,
    'multiline': multiline,
    'namesRoute': namesRoute,
    'obscured': obscured,
    'onCopy': onCopy,
    'onCut': onCut,
    'onDecrease': onDecrease,
    'onDidGainAccessibilityFocus': onDidGainAccessibilityFocus,
    'onDidLoseAccessibilityFocus': onDidLoseAccessibilityFocus,
    'onDismiss': onDismiss,
    'onIncrease': onIncrease,
    'onLongPress': onLongPress,
    'onLongPressHint': onLongPressHint,
    'onMoveCursorBackwardByCharacter': onMoveCursorBackwardByCharacter,
    'onMoveCursorForwardByCharacter': onMoveCursorForwardByCharacter,
    'onPaste': onPaste,
    'onScrollDown': onScrollDown,
    'onScrollLeft': onScrollLeft,
    'onScrollRight': onScrollRight,
    'onScrollUp': onScrollUp,
    'onSetSelection': onSetSelection,
    'onSetText': onSetText,
    'onTap': onTap,
    'onTapHint': onTapHint,
    'readOnly': readOnly,
    'scopesRoute': scopesRoute,
    'selected': selected,
    'slider': slider,
    'sortKey': null == sortKey ? null : sortKeyEncoded,
    'tagForChildren': ThemeEncoder.encodeSemanticsTag(
      tagForChildren,
    ),
    'textDirection': ThemeEncoder.encodeTextDirection(
      textDirection,
    ),
    'textField': textField,
    'toggled': toggled,
    'tooltip': tooltip,
    'value': value,
    'child': child?.toJson(),
    ...args,
  });
}