-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
base: master
Are you sure you want to change the base?
Migrate to use WidgetStateProperty
#174323
Conversation
There was a problem hiding this 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.
const WidgetStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>( | ||
Color(0xffFF0000), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the migration to WidgetStateProperty
, MaterialStatePropertyAll
should be changed to WidgetStatePropertyAll
.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elevationValue, | ||
); | ||
const MaterialStateProperty<Color?> backgroundColor = MaterialStatePropertyAll<Color>( | ||
const WidgetStateProperty<double?> elevation = MaterialStatePropertyAll<double>(elevationValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.).
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up of #174268
Final PR to migrate the usages of
MaterialStateProperty
toWidgetStateProperty
I'll work on the other elements of
packages/flutter/lib/src/material/material_state.dart
into other PRsPre-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.