简体   繁体   中英

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

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),
         
        ],
      ),
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM