Widget state properties (#142151)

Fixes #138270.

Moves the majority of the logic of MaterialStateProperties down to the widgets layer, then has the existing Material classes pull from the widgets versions.
This commit is contained in:
Mitchell Goodwin
2024-03-19 10:58:13 -07:00
committed by GitHub
parent 3236957f02
commit 6190c5eea1
36 changed files with 1435 additions and 545 deletions

View File

@@ -358,13 +358,13 @@ class _TextButtonExampleState extends State<TextButtonExample> {
},
style: TextButton.styleFrom(
overlayColor: Colors.transparent,
foregroundBuilder: (BuildContext context, Set<MaterialState> states, Widget? child) {
foregroundBuilder: (BuildContext context, Set<WidgetState> states, Widget? child) {
late final ImageProvider image;
if (currentAction != null) {
image = runningImage;
} else if (states.contains(MaterialState.pressed)) {
} else if (states.contains(WidgetState.pressed)) {
image = pressedImage;
} else if (states.contains(MaterialState.hovered)) {
} else if (states.contains(WidgetState.hovered)) {
image = hoveredImage;
} else {
image = defaultImage;