asBytes<E> method
Implementation
E asBytes<E>(String key) {
if (<int>[] is! E) {
throw const DartSuiPluginException(
'Invalid bytes casting. only use `valueAsList` method for bytes.',
);
}
final List? value = as(key);
if (value == null) {
if (null is E) {
return null as E;
}
throw DartSuiPluginException(
'Key not found.',
details: {'key': key, 'data': this},
);
}
try {
return value.cast<int>() as E;
} on TypeError {
throw DartSuiPluginException(
'Incorrect value.',
details: {
'key': key,
'expected': '$E',
'value': value.runtimeType,
'data': this,
},
);
}
}