AccessibilityEvent.fromMap constructor

AccessibilityEvent.fromMap(
  1. Map map
)

Implementation

AccessibilityEvent.fromMap(Map<dynamic, dynamic> map) {
  mapId = map['mapId'];
  nodeId = map['nodeId'];
  actionType = NodeAction.values
          .firstWhereOrNull((element) => element.id == map['actionType']) ??
      NodeAction.unknown;
  eventTime = DateTime.now();
  packageName = map['packageName'];
  if (map['eventType'] == null) {
    eventType = null;
  } else {
    eventType = EventType.values
        .firstWhereOrNull((element) => element.id == map['eventType']);
  }
  text = map['capturedText'].toString();
  contentChangeTypes = map['contentChangeTypes'] == null
      ? null
      : (ContentChangeTypes.values.firstWhereOrNull(
              (element) => element.id == map['contentChangeTypes']) ??
          ContentChangeTypes.others);
  movementGranularity = int.tryParse(map['movementGranularity'].toString());
  windowType = map['windowType'] == null
      ? null
      : WindowType.values
          .firstWhereOrNull((element) => element.id == map['windowType']);
  isActive = map['isActive'];
  isFocused = map['isFocused'];
  isClickable = map['isClickable'];
  isScrollable = map['isScrollable'];
  isFocusable = map['isFocusable'];
  isCheckable = map['isCheckable'];
  isLongClickable = map['isLongClickable'];
  isEditable = map['isEditable'];
  isPip = map['isPip'];
  screenBounds = map['screenBounds'] != null
      ? ScreenBounds.fromMap(map['screenBounds'])
      : null;
  subNodes = map['subNodesActions'] != null
      ? (map['subNodesActions'] as List<dynamic>)
          .map((e) => AccessibilityEvent.fromMap(e))
          .toList()
      : [];
  actions = map['parentActions'] == null
      ? []
      : (map['parentActions'] as List<dynamic>)
          .map((e) =>
              (NodeAction.values
                  .firstWhereOrNull((element) => element.id == e)) ??
              NodeAction.unknown)
          .toList();
}