[SOLVED] how to split a long string in flutter

Issue

This Content is from Stack Overflow. Question asked by Shafi Tlb

I have a large string with more than 1000 of characters.
I want to split the string with the length of each 100th character or by the length of the screen of mobile device and display the result page by page, want to scroll horizontally as well.



Solution

Just wrap with container and set width, It’ll automaticlly wrap according to screen size.

Container(
     width: MediaQuery.of(context).size.width,
     child: Text('Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the'),
);

or use Flexible

Container(
       child: Row(
         children: <Widget>[
            Flexible(
               child: new Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the"))
           ],
        ));


This Question was asked in StackOverflow by Shafi Tlb and Answered by Anandh Krishnan It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?