fromJson static method

ReorderConfig? fromJson(
  1. Object? value
)

Parses json['reorder'] leniently, unlike object/req: a malformed value (wrong type entirely, or a map missing a string column) reads as "this resource cannot be reordered" rather than throwing a SchemaFormatException that would blank the whole resource. Dropping a mobile-only affordance is a safe degrade; refusing to parse the rest of the schema over it is not.

Implementation

static ReorderConfig? fromJson(Object? value) {
  if (value is! Map<String, dynamic>) return null;

  final column = value['column'];
  if (column is! String || column.isEmpty) return null;

  // Same leniency as [ResourceSort.direction]'s `closedEnum(ifAbsent:
  // 'asc')` — an unrecognised or missing direction defaults rather than
  // throwing, since the server always sends both together in practice.
  return ReorderConfig(
    column: column,
    direction: value['direction'] == 'desc' ? 'desc' : 'asc',
  );
}