Hello this is vikash from India
I want to set and get image from local storage but i have not idea how to do this so , please help me to develop the logic
Thanks Vikash
CodePudding user response:
I don't know what your want image format is, but most likely you can use base64.
Probably this page will be helpful.
CodePudding user response:
I have done with the help of http and base64String
Future<String> getNetworkImage()async{
final data = await _firestore.collection("[email protected]").doc("GymDetails").get();
final imageurl = data.get("url");
final uri = Uri.parse(imageurl);
final response = await http.get(uri);
final unit8listimage = response.bodyBytes;
final base64image = base64Encode(unit8listimage);
final object = SetImage(imageurl: base64image);
if(!_objectBox.setimage.isEmpty()){
_objectBox.setimage.remove;
}
_objectBox.setimage.put(object);
final getimage = _objectBox.setimage.get(object.id);
return getimage!.imageurl;
}