-
Notifications
You must be signed in to change notification settings - Fork 110
Closed
Labels
type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
In contrast with read, peek should return a null value instead of throwing an exception if a field is not found. This allows a more graceful way of checking for this first non-null value, for example:
findTokenField(DartObject o) {
final reader = new ConstantReader(o);
final token = o.peek('token') ?? o.peek('_token');
}Other options:
- Add an
Function<Object> orElseparameter toread. - Add an explicit way to read/check many parameters, i.e.
final token = o.read('token', '_token');
// or
final token = o.readFirst(['token', '_token']);Metadata
Metadata
Assignees
Labels
type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug