I have to Render 2000 lines of text String into Textview in Flutter.
I have used setState((){ textString = "2000 lines of String...."; })
And used textString within Text().
but Application freezing UI for more than 10 seconds.
CodePudding user response:
I think it can be solved with asynchronous programming.
String textString = "";
Future<void> _renderText(String str) async{
setState(() {
textString = str;
});
}
@override
void initState() {
_renderText('2000line of String...');
super.initState();
}
If you use the button
TextButton(
onPressed: () async {
await _renderText('2000line of String...');
},
child: Text('Update'),
),
CodePudding user response:
"As per my observation data which is need to be updated to view is huge and its taking time to update at this case Application is crashing. For this am using pagination concept like split into multiple pieces and updating to View.
Ex: here am using length of the string, set maximum length of string to update view, based on this length splitting and updating view."