letIterableOrNone<T extends Object> function
Converts input
to Iterable<Option<T>>
, returning None on failure.
Supported types:
Implementation
Option<Iterable<Option<T>>> letIterableOrNone<T extends Object>(dynamic input) {
if (input is Outcome) {
return switch (input.rawSync().value) {
Ok(value: final okValue) => letIterableOrNone(
NoStackOverflowWrapper(okValue),
),
Err() => const None(),
};
}
return switch (input is NoStackOverflowWrapper ? input.value : input) {
final Iterable<dynamic> i => Some(i.map((e) => letOrNone<T>(e))),
final String s => jsonDecodeOrNone<Iterable<dynamic>>(
s,
).map((i) => i.map((e) => letOrNone<T>(e))),
_ => const None(),
};
}