Skip to content

Remove Material dependency from rotated_box_test.dart#181974

Closed
gbolahan507 wants to merge 1 commit intoflutter:masterfrom
gbolahan507:fix-rotated-box-test-cross-import
Closed

Remove Material dependency from rotated_box_test.dart#181974
gbolahan507 wants to merge 1 commit intoflutter:masterfrom
gbolahan507:fix-rotated-box-test-cross-import

Conversation

@gbolahan507
Copy link
Contributor

PR Description:

Remove Material dependency from rotated_box_test.dart

Replace Colors.blue[500] with const 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-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 the framework flutter/packages/flutter repository. See also f: labels. label Feb 5, 2026
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 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.

Comment on lines +26 to +32
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)),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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
  1. 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
@navaronbracke
Copy link
Contributor

This pull request is a duplicate of #181611 which includes rotated_box_test.dart among other cleanups

@gbolahan507
Copy link
Contributor Author

Thanks for letting me know! Closing in favor of #181611.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

Development

Successfully merging this pull request may close these issues.

3 participants