sathish kumar
sathish kumar

Reputation: 1109

Distinct like String Manipulation

I working on Flutter project. I have query regarding string manipulation. I storing some value like following

String a="31,31,31,31,31,31,31,41,41,41,41,41,41,41,41,41,41,53,53,53,53,53,53,53,53"

I have output like Distinct in query

a="31,41,53"

may I know how to achieve this function.

Thanks in advance Sathish

Upvotes: 1

Views: 40

Answers (1)

mezoni
mezoni

Reputation: 11210

void main() {
  String a =
      "31,31,31,31,31,31,31,41,41,41,41,41,41,41,41,41,41,53,53,53,53,53,53,53,53";
  var values = a.split(',');
  var result = Set.from(values).join(',');
  print(result);
}

Result:

31,41,53

Upvotes: 3

Related Questions