Created
July 10, 2020 17:55
-
-
Save GursheeshSingh/d9deecf017c51fce79a883dd3b1adc60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:typed_data'; | |
import 'package:http/http.dart' as http; | |
import 'package:image_picker/image_picker.dart'; | |
class UploadFile { | |
bool success; | |
String message; | |
bool isUploaded; | |
Future<void> call(String url, PickedFile image) async { | |
try { | |
Uint8List bytes = await image.readAsBytes(); | |
var response = await http.put(url, body: bytes); | |
if (response.statusCode == 200) { | |
isUploaded = true; | |
} | |
} catch (e) { | |
throw ('Error uploading photo'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment