The TextDirection docs say:
Flutter is designed to address the needs of applications written in any of the world's currently-used languages, whether they use a right-to-left or left-to-right writing direction. Flutter does not support other writing modes, such as vertical text or boustrophedon text, as these are rarely used in computer programs. (emphasis added)
Not only does Flutter not support vertical text, it won't be officially supported in the future. This was an early design decision (see here and here).
Even so, there is a real use for vertical script support today. In addition to certain Chinese and Japanese uses, the traditional Mongolian script requires it. This script is very commonly used in computer programs in Inner Mongolia (example, example, example, example, example, example).
It is written top to bottom, and lines wrap left to right:
Additionally, emoji and CJK characters retain the their orientation when displayed vertically (not absolutely necessary, but preferred). In the image below, the top paragraph shows the current implementation and the bottom paragraph shows the correct vertical rendering:
// sample text
ᠨᠢᠭᠡ ᠬᠣᠶᠠᠷ ᠭᠣᠷᠪᠠ ᠳᠥᠷᠪᠡ ᠲᠠᠪᠤ ᠵᠢᠷᠭᠤᠭᠠ ᠳᠣᠯᠣᠭᠠ ᠨᠠᠢᠮᠠ ᠶᠢᠰᠦ ᠠᠷᠪᠠ one two three four five six seven eight nine ten 😃🐐汉字 한국어 モンゴル語 English? ᠮᠣᠩᠭᠣᠯ︖
Since Flutter doesn't support vertical script, it must be implemented from scratch. All of the actual text layout and painting is done in the Flutter engine with LibTxt, so I can't change that.
What would it involve to create a top to bottom vertical Text widget?
Update
I'm still looking for an answer. Rémi's answer is good for single line text but doesn't work for multi-line text.
I'm currently researching three different possible solutions:
- Create a RenderObject subclass (or perhaps a RenderParagraph subclass) that backs a custom StatelessWidget similar to a RichText widget.
- Use a CustomPaint widget
- Make a composited widget of a ListView (one row per text line), Text widgets and WidgetSpans.
All of those would involve measuring the text, laying it out, and getting an list of lines.
Another update
I'm currently leaning toward making a custom widget and render object that will mimic RichText and RenderParagraph. Under the hood RenderParagraph uses a TextPainter to layout and paint the text. My problem now is that TextPainter is tightly coupled to the underlying Skia LibTxt library. That is where all the actual layout and painting happens. Laying out the text in anything besides the default ltr and rtl is proving to be a big problem.
Yet another update
The accepted answer meets the criteria I put forth in this question. I think it will meet short term needs. I have some reservations for things like applying text style, but I will need to do more tests. Long term I may still try to do custom text layout and painting.