Skip to content

Add drawPath documentation about preferring other methods for drawing simple shapes#184253

Open
b-luk wants to merge 1 commit intoflutter:masterfrom
b-luk:drawpath-docs
Open

Add drawPath documentation about preferring other methods for drawing simple shapes#184253
b-luk wants to merge 1 commit intoflutter:masterfrom
b-luk:drawpath-docs

Conversation

@b-luk
Copy link
Copy Markdown
Contributor

@b-luk b-luk commented Mar 27, 2026

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-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.

@b-luk b-luk added the CICD Run CI/CD label Mar 27, 2026
@github-actions github-actions bot added engine flutter/engine related. See also e: labels. and removed CICD Run CI/CD labels Mar 27, 2026
@b-luk b-luk requested a review from gaaclarke March 27, 2026 23:36
@gaaclarke
Copy link
Copy Markdown
Member

@b-luk did you want to change this from a draft?

@b-luk b-luk marked this pull request as ready for review March 27, 2026 23:42
@b-luk
Copy link
Copy Markdown
Contributor Author

b-luk commented Mar 27, 2026

Marked as ready for review. Forgot about that part.

Copy link
Copy Markdown
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 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.

Comment on lines +7294 to +7297
/// 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].
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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
  1. The style guide emphasizes optimizing for readability and ensuring documentation is useful. This change improves both by making the explanation clearer. (link)

Copy link
Copy Markdown
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm! thanks

@b-luk b-luk added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants