Answers for "Save a network image to local directory"

0

Save a network image to local directory

var response = await http.get(imgUrl);
Directory documentDirectory = await getApplicationDocumentsDirectory();
File file = new File(join(documentDirectory.path, 'imagetest.png'));
file.writeAsBytesSync(response.bodyBytes); // This is a sync operation on a real 
                                           // app you'd probably prefer to use writeAsByte and handle its Future
Posted by: Guest on June-06-2021

Browse Popular Code Answers by Language