Created
March 22, 2018 16:31
-
-
Save zoechi/ad30405f296a624bb0246c81948f0955 to your computer and use it in GitHub Desktop.
Uri.dataFromString() with smiley
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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