Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://stackoverflow.com/questions/55018479/offsets-are-different-ontap-and-ondrag-flutter
- https://pub.dev/packages/dio#examples
- class ServerProxy
- {
- Dio dio;
- Singleton._privateCtor() {
- BaseOptions options = new BaseOptions(
- baseUrl: "https://www.xx.com/api",
- connectTimeout: 5000,
- receiveTimeout: 3000,
- );
- dio = Dio(options);
- }
- static final ServerProxy _singleton = ServerProxy._privateCtor();
- factory ServerProxy() => _singleton;
- String getAsTextEndPoint = "/getAsText";
- Future<String> getAsText(Image img) {
- FormData formData = FormData.from({
- "file": await MultipartFile.fromFile(IDK_WHAT_TO_PUT_HERE, filename: "upload.txt") //TODO
- });
- Response response = await dio.post(
- getAsTextEndPoint,
- data: formData
- onSendProgress: (int sent, int total) { //TODO
- print("$sent $total");
- }
- );
- int statusCode = response.statusCode;
- const int SUCCESS_CODE = 123 //TODO
- if(statusCode != SUCCESS_CODE)
- throw("request unsuccessfu! [STATUS CODE: $statusCode");
- return response.data.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement