resolve method - FWidgetStateMap class - forui.theme library (original) (raw)
Returns a value that depends on states
by checking the constraints given in FWidgetStateMap.new.
Contract
Throws an ArgumentError if no constraints are satisfied and T
is non-nullable.
Implementation
@override
T resolve(Set<WidgetState> states) {
for (final MapEntry(key: constraint, :value) in _constraints.entries) {
if (constraint.isSatisfiedBy(states)) {
return value;
}
}
try {
return null as T;
// ignore: avoid_catching_errors
} on TypeError {
throw ArgumentError(
'The current set of widget states is $states.\n'
'None of the provided map keys matched this set, '
'and the type "$T" is non-nullable.\n'
'Consider using "FWidgetStateMap<$T?>()", '
'or adding the "WidgetState.any" key to this property.',
);
}
}