Last active
November 12, 2022 03:15
-
-
Save danielquisbert/59a97e717a0d6c5965c9cd37d0404225 to your computer and use it in GitHub Desktop.
Hack para guardar o convertir imagen en base 64
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
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