resolve method Null safety
- Set<
MaterialState> states
override
Returns a value of type T that depends on states.
Widgets like TextButton and ElevatedButton apply this method to their current MaterialStates to compute colors and other visual parameters at build time.
Implementation
@override
Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) {
return onPrimary.withOpacity(0.08);
}
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed)) {
return onPrimary.withOpacity(0.12);
}
return null;
}