Home > OS >  Covert String (looks like list format) into List
Covert String (looks like list format) into List

Time:11-03

  String testing = '["Template","Data","Manual","Checklist","Others"]';

How to convert this string (look like list) into the 'List-String'

CodePudding user response:

this is in JSON format, so you need just to decode it :

first, import the dart convert:

import "dart:convert";

then use the jsonDecode to get a list :

List list = jsonDecode(testing); 

this will result a List<dynamic>, then you can cast it's type if you want :

List<String>  listOfStrings = (jsonDecode(testing) as List).map((e) => e as String).toList(); 
  • Related