Skip to content

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

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
b-luk:drawpath-docs
Mar 28, 2026
Merged

Add drawPath documentation about preferring other methods for drawing simple shapes#184253
auto-submit[bot] merged 1 commit into
flutter:masterfrom
b-luk:drawpath-docs

Conversation

@b-luk

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

Copy link
Copy Markdown
Contributor

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

b-luk commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

Marked as ready for review. Forgot about that part.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

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)

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

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
@auto-submit auto-submit Bot added this pull request to the merge queue Mar 28, 2026
Merged via the queue into flutter:master with commit 9699417 Mar 28, 2026
188 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 28, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2026
@b-luk b-luk deleted the drawpath-docs branch March 30, 2026 16:27
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2026
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Apr 14, 2026
… simple shapes (flutter#184253)

Add drawPath documentation about preferring other methods for drawing
simple shapes

Part of flutter#183044

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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](https://developers.google.com/gemini-code-assist/docs/review-github-code).
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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants