Skip to content

Instantly share code, notes, and snippets.

@AdamMusa
Created August 17, 2020 16:25
Show Gist options
  • Save AdamMusa/0c4e519a66bc6a2b33b5da49a6f2bd49 to your computer and use it in GitHub Desktop.
Save AdamMusa/0c4e519a66bc6a2b33b5da49a6f2bd49 to your computer and use it in GitHub Desktop.
import 'package:cloudinary_client/cloudinary_client.dart';
import 'package:cloudinary_client/models/CloudinaryResponse.dart';
import 'package:flutter/foundation.dart' ;
class CloudImage with ChangeNotifier{
 dynamic _response;
 List<String> _urlList;
 bool _isloading = true ;
 dynamic get urlList => _urlList;
 String get response => _response;
 bool get isloading => _isloading;
Future<void> upload(List<String> imagesList) async{
 CloudinaryClient client = new CloudinaryClient(
 "your apiKey",
 "your apiSecret",
 "your cloudName",
 );
 List<CloudinaryResponse> response = await client.uploadImages(imagesList,filename: "MawCars");
 _response = response;
 notifyListeners();
 if(_response==null){
 return null;
 }
 else {
 List<String> urlList= [];
 _response.forEach((element){
 urlList.add(element.secure_url);
 });
 _urlList = urlList;
 _isloading = false;
 notifyListeners();
 }
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment