jsonObject function

Map<String, dynamic> jsonObject(
  1. Object? value, {
  2. required String description,
})

value, a decoded JSON value, which must be a JSON object.

description names the value in the FormatException thrown otherwise, for example the response body.

Implementation

Map<String, dynamic> jsonObject(
  Object? value, {
  required String description,
}) => switch (value) {
  final Map<String, dynamic> object => object,
  _ => throw FormatException(
    'Expected $description to be a JSON object, got ${value.runtimeType}',
  ),
};