Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strings.join removed in M3 - what is new syntax?

Tags:

dart

The code below no longer works in Dart M3, and I couldn't find what the new syntax is.

Could someone please advise?

#import('dart:uri');

String encodeMap(Map data) {
  return Strings.join(data.getKeys().map((k) {
    return "${encodeUriComponent(k)}=${encodeUriComponent(data[k])}";
  }), "&");
}
like image 413
Brian Oh Avatar asked Feb 25 '13 09:02

Brian Oh


1 Answers

Simply use .join(separator) on Iterable.

In your case :

import 'dart:uri';

String encodeMap(Map data) {
  return data.keys.map((k) {
    return "${encodeUriComponent(k)}=${encodeUriComponent(data[k])}";
  }).join("&");
}

From Breaking Change: Strings class is going away :

The Strings class (note the trailing "s") in core is going away.
If you used Strings.join(stringIterable, separator) replace it with stringIterable.join(separator).
If you used Strings.concatAll(stringIterable) replace it with stringIterable.join().

like image 69
Alexandre Ardhuin Avatar answered Nov 09 '22 06:11

Alexandre Ardhuin