I need to get strings of every "|" character.

String type = "123|234|24";

The output should be a list of strings.

List<String> subtypes = ["123","234","24"];

Solution 1: Viren V Varasadiya

You can use Split method as following.

 String type = "123|234|24";
  List<String> list = type.split('|').toList();

Solution 2: void

You can achieve this by using the split method on the String. Check the code below, it works well:

   String type = "123|234|24";
   // split the string using a pattern(|)
   final subtypes = type.split('|');
   // print the values


[123, 234, 24]

Note: You don't need to convert the subtypes to a list because Dart explicitly converts the result when the split method is used to a List