Skip to content

Instantly share code, notes, and snippets.

@GursheeshSingh
Created July 10, 2020 17:55
Show Gist options
  • Save GursheeshSingh/d9deecf017c51fce79a883dd3b1adc60 to your computer and use it in GitHub Desktop.
Save GursheeshSingh/d9deecf017c51fce79a883dd3b1adc60 to your computer and use it in GitHub Desktop.
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