[英]Long text phrases (Flutter)
I'm wondering what the best practice is for longer text phrases.我想知道较长文本短语的最佳做法是什么。 eg in a portfolio program which has longer text section explaining your experience in programming, how is the proper way to handle the following text widget?
例如,在一个有较长文本部分解释您的编程经验的投资组合程序中,如何正确处理以下文本小部件?
Text('A very long text piece that is way longer that 80 characters, a very long text piece that is way longer that 80 characters, a very long text piece that is way longer that 80 characters, a very long text piece that is way longer that 80 characters')
I thought about storing it in a JSON file or similar, but that would slow the program, as it would have to convert the JSON file to the object. Also thought about storing the text in a map, such that the 'ugly' code would be hidden away, but yet again it seems a bit lazy and would also obscure the structure a bit, making the code harder to navigate我考虑过将它存储在 JSON 文件或类似文件中,但这会减慢程序,因为它必须将 JSON 文件转换为 object。还考虑将文本存储在 map 中,这样“丑陋”的代码就会被隐藏起来,但又一次看起来有点懒惰,也会使结构有点模糊,使代码更难导航
Wrap it in a container with limited width to limit it.将其包裹在宽度有限的容器中以限制它。 Example,
例子,
double width = MediaQuery.of(context).size.width*0.8;(//80% of screen.
return new Container (
padding: const EdgeInsets.all(16.0),
width: width,
child: new Column (
children: <Widget>[
new Text ("Long text......................", textAlign: TextAlign.left),
],
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.