Select multiple images with Flutter
1 min readJan 8, 2019
Introduction
Click here for open plug-in
Edit pubspec.yml.
dependencies:
flutter:
sdk: flutter multi_image_picker: ^2.2.55
After editing, execute the following comment
flutter packages get
Implementation
This time I write the implementation posting on Firebase Storage together. For detailed implementation of Firebase Storage please see below
import 'package:multi_image_picker/multi_image_picker.dart';_getImageList() async {
var resultList = await MultiImagePicker.pickImages(
maxImages : 10 ,
enableCamera: true,
);
// The data selected here comes back in the list
print(resultList); for ( var imageFile in resultList) {
postImage(imageFile).then((downloadUrl) {
// Get the download URL
print(downloadUrl.toString());
}).catchError((err) {
print(err);
});
}
} Future<dynamic> postImage(Asset imageFile) async {
await imageFile.requestOriginal(); String fileName = DateTime.now().millisecondsSinceEpoch.toString();
StorageReference reference = FirebaseStorage.instance.ref().child(fileName);
StorageUploadTask uploadTask = reference.putData(imageFile.imageData.buffer.asUint8List());
StorageTaskSnapshot storageTaskSnapshot = await uploadTask.onComplete; return storageTaskSnapshot.ref.getDownloadURL();
}
So far
Up to now it was impossible to register such multiple images. So, in my own application, we implemented Swift and Kotlin code separately, but I thought that I could delete them all on this machine! Management is easy! ! ! !