Add locale parameter to EditableText#18222
Conversation
There was a problem hiding this comment.
we should probably mention briefly what null means
|
As discussed offline, I realized while reviewing this patch that we do need to have the Locale on the TextStyle, because a single Text widget can have multiple parts of its text with different locales, e.g. "The English word foo is bar in Japanese and baz in Chinese" would have three locales. The TextStyle should probably default to null locale and then Text can fill it in from the ambient Locale. |
4dc7e11 to
a62aba1
Compare
If you create a RichText with TextSpans whose TextStyles have non-null locales, the RichText will carry the ambient locale and the TextSpan styles will carry along their locales via the ui.ParagraphBuilder. In this case the engine uses the text style's locale. I've verified that this works. Will add tests when tests can use fonts. |
|
Can you add the test anyway today (as a golden test) and then add a TODO to enable it, with a link to the relevant font bug? That way when we implement it we'll have a better chance to also update the test. |
| /// This property is rarely set. Typically the locale used to select | ||
| /// region-specific glyphs is defined by the text widget's [BuildContext] | ||
| /// using `Localizations.localeOf(context)`. For example [RichText] defines | ||
| /// its locale this way. However a rich text widget's [TextSpan]s could specify |
| /// the Chinese and Japanese locales. In these cases the [locale] may be used | ||
| /// to select a locale-specific font. | ||
| /// | ||
| /// If this value is null, a system dependent algorithm is used to select |

The RenderParagraph and RenderEditableText renderers now pass the locale along to the engine via their internal TextPainters (see also #18189, #17879). The locale is typically defined by the app and text widgets look it up with Localizations.localeOf().