Skip to content

Instantly share code, notes, and snippets.

@zoechi
Created March 22, 2018 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoechi/ad30405f296a624bb0246c81948f0955 to your computer and use it in GitHub Desktop.
Save zoechi/ad30405f296a624bb0246c81948f0955 to your computer and use it in GitHub Desktop.
Uri.dataFromString() with smiley
final content1 = 'hello world';
final content2 = '❤';
void main() {
final dataUri1 = createDataUri(content1);
print(dataUri1);
final dataUri2 = createDataUri(content2);
print(dataUri2);
}
String createDataUri(String content) {
String result;
try {
result = new Uri.dataFromString(content, mimeType: 'text/html').toString();
} catch (e) {
result = '$e';
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment