For downloading an image from URL, use image_downloader package like this :
try { // Saved with this method. var imageId = await ImageDownloader.downloadImage("https://raw.githubusercontent.com/wiki/ko2ic/image_downloader/images/flutter.png"); if (imageId == null) { return; } // Below is a method of obtaining saved image information. var fileName = await ImageDownloader.findName(imageId); var path = await ImageDownloader.findPath(imageId); var size = await ImageDownloader.findByteSize(imageId); var mimeType = await ImageDownloader.findMimeType(imageId); } on PlatformException catch (error) { print(error); }
For uploading an image to server use below code:
import 'package:path/path.dart'; import 'package:async/async.dart'; import 'dart:io'; import 'package:http/http.dart' as http; Upload(File imageFile) async { var stream = new http.ByteStream(DelegatingStream.typed(imageFile.openRead())); var length = await imageFile.length(); var uri = Uri.parse(uploadURL); var request = new http.MultipartRequest("POST", uri); var multipartFile = new http.MultipartFile('file', stream, length, filename: basename(imageFile.path)); //contentType: new MediaType('image', 'png')); request.files.add(multipartFile); var response = await request.send(); print(response.statusCode); response.stream.transform(utf8.decoder).listen((value) { print(value); }); }
You can also refer to this tutorial for learning image upload in Flutter.
For showing an image from server URL use this code :
Image.network( imageUrl, )
Here imageUrl can be any image URL like
https://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png
"How to show Image from String Url in flutter?"? you want to upload or download? what actually do you want to achieve?