Remove Material dependency from rotated_box_test.dart#181974
Remove Material dependency from rotated_box_test.dart#181974gbolahan507 wants to merge 1 commit intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request successfully removes the Material dependency from rotated_box_test.dart by replacing Colors.blue[500] with its equivalent const Color(0xFF2196F3) and updating the import from material.dart to widgets.dart. The change is also reflected by correctly removing the test file from the cross-import allowlist. I have one suggestion to define the hardcoded color as a constant to improve code readability and maintainability.
| child: Container(width: 100.0, height: 40.0, color: const Color(0xFF2196F3)), | ||
| ), | ||
| GestureDetector( | ||
| onTap: () { | ||
| log.add('right'); | ||
| }, | ||
| child: Container(width: 75.0, height: 65.0, color: Colors.blue[500]), | ||
| child: Container(width: 75.0, height: 65.0, color: const Color(0xFF2196F3)), |
There was a problem hiding this comment.
To improve readability and maintainability, consider defining this color as a named constant. This avoids using a 'magic number' for the color and makes it easier to update if needed, especially since it's used in two places.
For example, you could add this at the beginning of the test body:
const Color kTestColor = Color(0xFF2196F3);And then use kTestColor in both Container widgets.
References
- Code should be optimized for readability. Using named constants for repeated magic values like colors improves readability and maintainability. (link)
Replace Colors.blue[500] with a named constant _kTestColor to remove the Material library dependency from this widgets test. Part of flutter#177414
f06d663 to
f093f6c
Compare
|
This pull request is a duplicate of #181611 which includes rotated_box_test.dart among other cleanups |
|
Thanks for letting me know! Closing in favor of #181611. |
PR Description:
Remove Material dependency from rotated_box_test.dart
Replace
Colors.blue[500]withconst Color(0xFF2196F3)to remove the Material library dependency from this widgets test.Part of #177414
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-assistbot 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.