OneOf<T> constructor
OneOf<T> (
- T? resolve(
- dynamic json,
- NyResponse response
Decodes with resolve, which gets the body and the whole response and
returns the value, or null for a shape it doesn't recognise.
OrderResult: OneOf<OrderResult>((json, response) => switch ((response.statusCode, json)) {
(200, {'status': 'placed'}) => OrderPlaced.fromJson(json),
(200, _) => OrderPending.fromJson(json),
_ => null,
}),
Implementation
OneOf(this.resolve);