handle method
List<T>
handle(
- dynamic value, {
- List<
T> ? defaultValue, - bool skipInvalid = false,
- SuperConverter<
T> ? converter,
override
Implementation
@override
List<T> handle(
value, {
List<T>? defaultValue,
bool skipInvalid = false,
/// to use single time used converter
SuperConverter<T>? converter,
}) {
if (value == null || value == [] || value == '') {
if (defaultValue != null) return defaultValue;
}
if (value is String && value.isNotEmpty) value = jsonDecode(value);
if (value is! List) {
value = [value];
}
List<T> response = [];
for (var e in value) {
try {
response.add(SuperConverter.convert<T>(e, converter: converter));
} catch (e) {
if (skipInvalid) {
// print(
// '[CustomConverter][ListConverter<$T>] '
// 'skip invalid item ${value.toString().padRight(100).substring(0, 100)}',
// );
} else {
rethrow;
}
}
}
return response;
}