How to Display Text Over Two Lines in Flutter's AppBar Flutter AppBar Text
Автор: vlogize
Загружено: 2025-05-28
Просмотров: 1
Описание:
Discover how to display long text across two lines in Flutter's AppBar without it getting truncated. Follow our step-by-step guide for a seamless user interface experience.
---
This video is based on the question https://stackoverflow.com/q/66965251/ asked by the user 'SylvainJack' ( https://stackoverflow.com/u/15349168/ ) and on the answer https://stackoverflow.com/a/66965295/ provided by the user 'Nilesh Senta' ( https://stackoverflow.com/u/4303352/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.
Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: In Flutter/Dart : Display text in AppBar over two lines?
Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.
If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
How to Display Text Over Two Lines in Flutter's AppBar
When developing mobile applications with Flutter, you might encounter a scenario when your AppBar needs to display a title that is longer than one line. This can lead to the text getting truncated, leaving users with an incomplete view due to the limitations of the display area. Fortunately, there is a simple solution to allowing your text to wrap onto two lines instead of being cut off.
Understanding the Problem
In the provided code, the AppBar is structured using a Row, which includes two images on either side of the title text. The title text is set to uppercase and has a defined font size. However, when the text exceeds a certain length, it gets truncated with an ellipsis ("..."), which is not ideal for user experience since users can't see the complete title.
Example of the Current Code Structure
Here is a simplified version of your current setup:
[[See Video to Reveal this Text or Code Snippet]]
The Solution
To ensure that the title can wrap onto two lines, you need to make a small adjustment to your Text widget's properties by adding the maxLines property.
Step-by-step Modification
Locate the Text widget within the Expanded widget:
[[See Video to Reveal this Text or Code Snippet]]
Update the Text widget by adding maxLines: 2:
[[See Video to Reveal this Text or Code Snippet]]
Modified Example Code
Here’s how your modified AppBar code would look:
[[See Video to Reveal this Text or Code Snippet]]
Conclusion
By adding maxLines: 2 to the Text widget, you allow the title text in the AppBar to expand to two lines instead of being truncated with an ellipsis. This change enhances usability, ensuring that users have a complete view of the title, regardless of its length.
Implement these changes in your Flutter application and improve your AppBar's presentation—your users will appreciate the clarity!
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: