fromObjectList<N, E> static method

EncodableValue fromObjectList<N, E>(
  1. List<N> list, {
  2. ObjectEncoder<N, E>? encoder,
})

Creates an EncodableValue from list.

list is not supposed to be directly encodable. As such, encoder is used to convert every element of the list to an encodable object.

If encoder is omitted, the result of calling .toJson() on each list element will be used.

Throws a JsonPreparationError if:

  • encoder is provided, but E could not represent an encodable object.
  • list elements do not have a callable .toJson() method.
  • E does not match the .toJson() result type.

Implementation

static EncodableValue fromObjectList<N, E>(List<N> list,
    {ObjectEncoder<N, E>? encoder}) {
  return EncodableValue._(prepareObjectList<N, E>(list, encoder));
}