Skip to content

Commit c575638

Browse files
authored
Update documentation on TextPainter to note default color differences (#165048)
This change only changes the documentation of `TextPainter`. Previously, the documentation was incorrect in stating that the default text color was white. It changes depending on platform to be contrasted to the canvas' background color. This is in an "important" box because it affects apps working on native & web, and is relatively easy to miss. It may be worth documenting this elsewhere? Fixes #165047 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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 `///`). - [ ] 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]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [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
1 parent 9ad5fc2 commit c575638

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/flutter/lib/src/painting/text_painter.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,9 @@ class _LineCaretMetrics {
583583
/// changes, return to step 2. If the text to be painted changes,
584584
/// return to step 1.
585585
///
586-
/// The default text style is white. To change the color of the text,
587-
/// pass a [TextStyle] object to the [TextSpan] in `text`.
586+
/// The default text style color is white on non-web platforms and black on
587+
/// the web. If developing across both platforms, always set the text color
588+
/// explicitly.
588589
class TextPainter {
589590
/// Creates a text painter that paints the given text.
590591
///

0 commit comments

Comments
 (0)