Add drawPath documentation about preferring other methods for drawing simple shapes#184253
Add drawPath documentation about preferring other methods for drawing simple shapes#184253b-luk wants to merge 1 commit intoflutter:masterfrom
Conversation
|
@b-luk did you want to change this from a draft? |
|
Marked as ready for review. Forgot about that part. |
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for the drawPath method in the Canvas class to recommend using specialized methods like drawRect or drawOval for simple shapes to improve efficiency. Feedback suggests rephrasing the documentation to clarify that the performance benefit comes from avoiding the creation of a Path object.
| /// When drawing simple shapes (such as rectangles, ovals, or rounded | ||
| /// rectangles), prefer using methods such as [drawRect], [drawOval], or | ||
| /// [drawRRect] over [drawPath]. Methods that draw simple shapes are generally | ||
| /// more efficient than drawing a [Path]. |
There was a problem hiding this comment.
For improved clarity, consider rephrasing this paragraph. The current wording '...more efficient than drawing a [Path]' is slightly ambiguous because [Path] refers to the class, not an action. A more explicit phrasing could better explain the alternative workflow that is being discouraged.
/// When drawing simple shapes (such as rectangles, ovals, or rounded
/// rectangles), prefer using methods such as [drawRect], [drawOval], or
/// [drawRRect] over [drawPath]. These dedicated methods are generally more
/// efficient than creating a [Path] and drawing it with this method.References
- The style guide emphasizes optimizing for readability and ensuring documentation is useful. This change improves both by making the explanation clearer. (link)
Add drawPath documentation about preferring other methods for drawing simple shapes
Part of #183044
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.