Home > Enterprise >  split a String into colums list in dart-flutter
split a String into colums list in dart-flutter

Time:12-07

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

CodePudding user response:

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

String data = "example#example";
var list = data.split('#');
print(list);

CodePudding user response:

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

CodePudding user response:

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)),
  ],
);
  • Related