Created
December 3, 2020 13:58
-
-
Save SandroMaglione/731a53d41962cb10ef15131d8aec4af7 to your computer and use it in GitHub Desktop.
Convert from and to base64 a String in dart
This file contains 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
import 'dart:convert'; | |
/// Manage conversion to and from base 64 | |
mixin Base64Mixin { | |
/// Converts a [dynamic] data from plain [String] to base64 | |
String toBase64(dynamic data) => base64.encode(utf8.encode(jsonEncode(data))); | |
/// Converts a [dynamic] data from base64 to plain [String] | |
String fromBase64(dynamic data) => utf8.decode(base64.decode(data as String)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment