简体   繁体   中英

(Flutter/Dart) How to fix displaying numbers from list with [ ]

So when getting this list from a csv file, it displays in the table as follows:

[1] [2] [3] [4]

I want just the numbers to get displayed, the file they're stored in does not contain the [] just the numbers. This is the code to fetch it:

final myData = await rootBundle.loadString("assets/Prod.csv");
List<List<dynamic>> csvTable = CsvToListConverter().convert(myData);
print(csvTable);

The print shows the following: [[1], [2], [3], [4]]

Fyi there's another file where the numbers are displayed just fine and the list is stored and fetched the same way so I'm not sure where's the problem here.

List<int> listOfInt = [];
List<List<dynamic>> csvTable = CsvToListConverter().convert(myData);
for ( var row in csvTable){
 for {var num in row){
   listOfInt.add(num);
 }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM