Home > database >  how to remove a [ ] symbol from Flutter Strings?
how to remove a [ ] symbol from Flutter Strings?

Time:08-22

excuse me,

can i ask help about my Flutter project, sqflite offline database, which i want to convert String to list, but there some issue: the [ ] symbol still there on List data, the question is, how to remove [ ] symbol from string data?

From: String data = '[data0, data1, data2]';

to: String data = 'data0, data2, data2';

thanks for answering, greeting from Indonesia

CodePudding user response:

If you want to remove all [ and ] use .replaceAll

  final result = data.replaceAll("[", "").replaceAll("]", "");

Also you can use Regex

CodePudding user response:

Remove first and last charcters as this:

final newString = data.substring(1, data.length() - 1)
  • Related