Display Long form text in Text Widget : Flutter

7.5k views Asked by At

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.

2

There are 2 answers

0
August Kimo On BEST ANSWER
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'),
    ],
  ),
)
0
DavidAma On

try this, it helped me with my past knowledge from HTML CSS JS

return Scaffold(
      body: SingleChildScrollView(
        child: Column(children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text("Privacy Policy",
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: 32,
                    )),
                IconButton(
                  icon: Icon(
                    Icons.close,
                  ),
                  iconSize: 24,
                  onPressed: () {
                    Get.back();
                  },
                )
              ],
            ),
          ), 
      
          Text(
          
         """
formation to us then you agree to provide true, 
current, complete and accurate information, and 
not to misrepresent your identity.  You also 
agree to keep Your Information current and to 
update Your Information if any of Your 
Information changes.
          """)
        ]),
      ),
    );