Skip to content

Migrate to use WidgetStateProperty #174323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ValentinVignal
Copy link
Contributor

Follow up of #174268

Final PR to migrate the usages of MaterialStateProperty to WidgetStateProperty

I'll work on the other elements of packages/flutter/lib/src/material/material_state.dart into other PRs

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Aug 23, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates usages of MaterialStateProperty to WidgetStateProperty across various test files, which is a good step towards modernizing the API usage. The changes are largely correct. However, I've noticed some inconsistencies where related classes like MaterialStatePropertyAll and MaterialStateColor were not updated to their WidgetState* counterparts. I've added specific comments to highlight these areas to ensure the migration is consistent throughout the codebase.

Comment on lines +1426 to 1428
const WidgetStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(
Color(0xffFF0000),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to WidgetStateProperty, MaterialStatePropertyAll should be changed to WidgetStatePropertyAll.

Suggested change
const WidgetStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(
Color(0xffFF0000),
);
const WidgetStateProperty<Color> headingRowColor = WidgetStatePropertyAll<Color>(
Color(0xffFF0000),
);

@@ -903,7 +903,7 @@ void main() {
return inactiveEnabledFillColor;
}

final MaterialStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to WidgetStateProperty, MaterialStateColor should be changed to its new equivalent WidgetStateColor. This applies to other occurrences in this file as well.

Suggested change
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = WidgetStateColor.resolveWith(getFillColor);

@@ -1153,7 +1154,7 @@ void main() {
return inactiveEnabledFillColor;
}

final MaterialStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to WidgetStateProperty, MaterialStateColor should be changed to its new equivalent WidgetStateColor. This applies to other occurrences in this file as well.

    final WidgetStateProperty<Color> fillColor = WidgetStateColor.resolveWith(getFillColor);

elevationValue,
);
const MaterialStateProperty<Color?> backgroundColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<double?> elevation = MaterialStatePropertyAll<double>(elevationValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to WidgetStateProperty, MaterialStatePropertyAll should be changed to WidgetStatePropertyAll. This applies to all similar properties in this block (backgroundColor, shadowColor, etc.).

Suggested change
const WidgetStateProperty<double?> elevation = MaterialStatePropertyAll<double>(elevationValue);
const WidgetStateProperty<double?> elevation = WidgetStatePropertyAll<double>(elevationValue);

@@ -748,7 +748,7 @@ void main() {
return inactiveEnabledThumbColor;
}

final MaterialStateProperty<Color> thumbColor = MaterialStateColor.resolveWith(getThumbColor);
final WidgetStateProperty<Color> thumbColor = MaterialStateColor.resolveWith(getThumbColor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to WidgetStateProperty, MaterialStateColor should be changed to its new equivalent WidgetStateColor. This applies to other occurrences in this file as well.

Suggested change
final WidgetStateProperty<Color> thumbColor = MaterialStateColor.resolveWith(getThumbColor);
final WidgetStateProperty<Color> thumbColor = WidgetStateColor.resolveWith(getThumbColor);

@@ -2272,7 +2273,7 @@ void main() {
return inactiveEnabledThumbColor;
}

final MaterialStateProperty<Color> thumbColor = MaterialStateColor.resolveWith(getThumbColor);
final WidgetStateProperty<Color> thumbColor = MaterialStateColor.resolveWith(getThumbColor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to WidgetStateProperty, MaterialStateColor should be changed to its new equivalent WidgetStateColor. This applies to other occurrences in this file as well.

    final WidgetStateProperty<Color> thumbColor = WidgetStateColor.resolveWith(getThumbColor);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant