valueAsBytes<T extends List<int>? > method
T
valueAsBytes<T extends List<int>? >(
- K key, {
- bool allowHex = true,
- StringEncoding? encoding,
- bool allowJson = false,
- T onMissing()?,
- bool acceptSnakeCase = false,
- bool acceptCamelCase = false,
- T onError(
- JsonParserError err
Implementation
T valueAsBytes<T extends List<int>?>(
K key, {
bool allowHex = true,
StringEncoding? encoding,
bool allowJson = false,
T Function()? onMissing,
/// Also accepts the snake_case or camel_case version of [key] when looking up JSON fields.
/// Only applicable when [K] is `String`.
bool acceptSnakeCase = false,
bool acceptCamelCase = false,
T Function(JsonParserError err)? onError,
}) {
try {
final value = _checkItem<T>(
key,
onMissing,
acceptSnakeCase,
acceptCamelCase,
);
if (value == null) return value as T;
return JsonParser.valueAsBytes<T>(
value,
allowHex: allowHex,
encoding: encoding,
allowJson: allowJson,
);
} on JsonParserError catch (e) {
if (onError != null) return onError(e);
rethrow;
}
}