skip to Main Content

How to split this "example#example"
To show like this

like columns
1.example
2.example

final String list = data!.list!.split('#').first;

result >>>> example

How to show

example
example 

from example#example

3

Answers


  1. You can change list type to var and get rid of first

    String data = "example#example";
    var list = data.split('#');
    print(list);
    
    Login or Signup to reply.
  2. data.split('#') will provide a list. You can loop though item.

      final data = "example#example";
      final list = data.split('#');
      for (final item in list) { // will print one by one.
        print(item);
      }
      final outPut = list.join(" "); //You can join the list. 
      print(outPut); //example example
    
    Login or Signup to reply.
  3. If you mean to widget not printing, here’s a solution.

    const String data = "example#example";
    final List<String> list = data.split('#');
    return Column(
      children: <Widget>[
        ...list.map((String e) => Text(e)),
      ],
    );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search