Skip to content

Instantly share code, notes, and snippets.

@danielquisbert
Last active November 12, 2022 03:15
Show Gist options
  • Save danielquisbert/59a97e717a0d6c5965c9cd37d0404225 to your computer and use it in GitHub Desktop.
Save danielquisbert/59a97e717a0d6c5965c9cd37d0404225 to your computer and use it in GitHub Desktop.
Hack para guardar o convertir imagen en base 64
FutureBuilder(
future: getImageBase64(),
initialData: ObjectClass, // puede ser String
builder: (BuildContext context, AsyncSnapshot<GeneraQRModel> snapshot) {
if (snapshot.hasData) {
final data = snapshot.data!;
if (snapshot.connectionState == ConnectionState.done) {
String uri = 'data:image/png;base64,${data!['imageBase64']}';
Uint8List _imageData = base64.decode(uri.split(',').last);
final result = await ImageGallerySaver.saveImage(
Uint8List.fromList(_imageData),
quality: 60, // tamaño de la imagen
name: "nombreImagen");
if (result['isSuccess']) {
print("Ok");
}else {
print("Error");
}
} else {
return Utils.loadingCustom();
}
} else {
return Utils.loadingCustom();
}
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment