How to convert String to List<int> in Dart?

Viewed 1216

String data= '[1, 2, 3]';

i want to convert my string to List<int>

expectations: [1, 2, 3]

what i got using my code:

print(json.decode(data));

result: 1

dataType: int

1 Answers

You can do this,

import 'dart:convert';

var list = json.decode(data);
Related