resolve method
- Set<
WidgetState> states
override
Returns a value of type T
that depends on states
.
Widgets like TextButton and ElevatedButton apply this method to their current WidgetStates to compute colors and other visual parameters at build time.
Implementation
@override
T resolve(Set<WidgetState> states) {
for (final MapEntry<WidgetStatesConstraint, T> entry in _map.entries) {
if (entry.key.isSatisfiedBy(states)) {
return entry.value;
}
}
try {
return null as T;
} on TypeError {
throw ArgumentError(
'The current set of material states is $states.\n'
'None of the provided map keys matched this set, '
'and the type "$T" is non-nullable.\n'
'Consider using "WidgetStateProperty<$T?>.fromMap()", '
'or adding the "WidgetState.any" key to this map.',
);
}
}