'Flutter - How to split string by space in the stateful widget?

I'm still new to coding and I don't know how to split string in the stateful widget.




Solution 1:[1]

to split String str = "Hello World!";

you can simply use split method like str.split(' ')

Refer this official documentation.

Solution 2:[2]

You can use String's .split() method to achieve this, passing in a string containing just a space as your delimiter. For example:

'Hello World'.split(' ') will return ['Hello', 'World'].

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pathik Patel
Solution 2 Sylith