fromObject<N, E> static method
Creates an EncodableValue from value
.
value
is not supposed to be directly encodable. As such, encoder
is
used to convert it to an encodable object.
If encoder
is omitted, the result of calling .toJson()
on value
will be used.
Throws a JsonPreparationError if:
encoder
is provided, butE
could not represent an encodable object.value
does not have a callable.toJson()
method.E
does not match the.toJson()
result type.
Implementation
static EncodableValue fromObject<N, E>(N value,
{ObjectEncoder<N, E>? encoder}) {
return EncodableValue._(prepareObject<N, E>(value, encoder));
}