flutterdartflutter-layouttext-widget

Display Long form text in Text Widget : Flutter


I'm trying to create Legal pages in my app such as terms and conditions and privacy policy pages.

Does Flutter have a widget that is specifically design to take in long form text besides using the default Text widget? Or is there a hack to this? Perhaps reading from a text file or so?

I'm trying to avoid using multiple Text widgets in my dart file to display my long form legal pages.

Thanks.


Solution

  • Expanded(            
        child: Text(
          'a long text',
          overflow: TextOverflow.clip,
        ),
    ),
    

    If you have various styling in the Text you can use RichText

    RichText(
      overflow: TextOverflow.clip
      text: TextSpan(
        text: 'Hello ',
        style: DefaultTextStyle.of(context).style,
        children: <TextSpan>[
          TextSpan(text: 'Super long bolded text here', style: TextStyle(fontWeight: FontWeight.bold)),
          TextSpan(text: 'Super long unbolded text here'),
        ],
      ),
    )