change all api from http to dio
This commit is contained in:
@ -3,18 +3,28 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
// import 'dart:convert';
|
||||||
|
// import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
// import 'package:get/get.dart';
|
||||||
import 'package:get_storage/get_storage.dart';
|
import 'package:get_storage/get_storage.dart';
|
||||||
import 'package:http/http.dart' as http;
|
// import 'package:http/http.dart' as http;
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
|
|
||||||
class BeforeLoginApi extends GetxController {
|
class BeforeLoginApi {
|
||||||
static final log = Logger();
|
static final log = Logger();
|
||||||
static var storage = GetStorage();
|
static var storage = GetStorage();
|
||||||
|
|
||||||
|
static var options = BaseOptions(
|
||||||
|
// baseUrl: 'https://www.xx.com/api',
|
||||||
|
connectTimeout: 5000,
|
||||||
|
receiveTimeout: 5000,
|
||||||
|
);
|
||||||
|
Dio dio = Dio(options);
|
||||||
|
|
||||||
Future<Map<String, dynamic>> sign_up_kurir(Map data, String fotoKTP,
|
Future<Map<String, dynamic>> sign_up_kurir(Map data, String fotoKTP,
|
||||||
String fotoHoldingKTP, String fotoKendaraan, String fotoProfil) async {
|
String fotoHoldingKTP, String fotoKendaraan, String fotoProfil) async {
|
||||||
Map<String, dynamic> result;
|
Map<String, dynamic> result;
|
||||||
@ -27,24 +37,44 @@ class BeforeLoginApi extends GetxController {
|
|||||||
status: 'Melakukan\nPendaftaran...',
|
status: 'Melakukan\nPendaftaran...',
|
||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
var postUri = Uri.parse('${globals.http_to_server}api/login/daftar1');
|
// var postUri = Uri.parse('${globals.http_to_server}api/login/daftar1');
|
||||||
var request = http.MultipartRequest("POST", postUri);
|
// var request = http.MultipartRequest("POST", postUri);
|
||||||
request.fields['data'] = jsonEncode(data);
|
// request.fields['data'] = jsonEncode(data);
|
||||||
request.files
|
// request.files
|
||||||
.add(await http.MultipartFile.fromPath('ktp_photo', fotoKTP));
|
// .add(await http.MultipartFile.fromPath('ktp_photo', fotoKTP));
|
||||||
request.files.add(await http.MultipartFile.fromPath(
|
// request.files.add(await http.MultipartFile.fromPath(
|
||||||
'ktp_holding_photo', fotoHoldingKTP));
|
// 'ktp_holding_photo', fotoHoldingKTP));
|
||||||
request.files.add(await http.MultipartFile.fromPath(
|
// request.files.add(await http.MultipartFile.fromPath(
|
||||||
'kenderaan_photo', fotoKendaraan));
|
// 'kenderaan_photo', fotoKendaraan));
|
||||||
request.files
|
// request.files
|
||||||
.add(await http.MultipartFile.fromPath('photo', fotoProfil));
|
// .add(await http.MultipartFile.fromPath('photo', fotoProfil));
|
||||||
|
|
||||||
var streamResponse =
|
// var streamResponse =
|
||||||
await request.send().timeout(const Duration(seconds: 120));
|
// await request.send().timeout(const Duration(seconds: 120));
|
||||||
// var streamResponse = await request.send();
|
// // var streamResponse = await request.send();
|
||||||
var response = await http.Response.fromStream(streamResponse);
|
// var response = await http.Response.fromStream(streamResponse);
|
||||||
|
|
||||||
final datanya = jsonDecode(response.body);
|
// final datanya = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var formData = FormData.fromMap({
|
||||||
|
'data': jsonEncode(data),
|
||||||
|
'ktp_photo': await MultipartFile.fromFile(fotoKTP),
|
||||||
|
'ktp_holding_photo': await MultipartFile.fromFile(fotoHoldingKTP),
|
||||||
|
'kenderaan_photo': await MultipartFile.fromFile(fotoKendaraan),
|
||||||
|
'photo': await MultipartFile.fromFile(fotoProfil),
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await dio.post(
|
||||||
|
'${globals.http_to_server}api/login/daftar1',
|
||||||
|
data: formData,
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
var datanya = response.data;
|
||||||
|
|
||||||
log.i(response.statusCode.toString() + " ini status code");
|
log.i(response.statusCode.toString() + " ini status code");
|
||||||
log.i(datanya.toString());
|
log.i(datanya.toString());
|
||||||
@ -116,17 +146,36 @@ class BeforeLoginApi extends GetxController {
|
|||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
|
|
||||||
var postUri = Uri.parse('${globals.http_to_server}api/login/daftar1');
|
// var postUri = Uri.parse('${globals.http_to_server}api/login/daftar1');
|
||||||
var request = http.MultipartRequest("POST", postUri);
|
// var request = http.MultipartRequest("POST", postUri);
|
||||||
request.fields['data'] = jsonEncode(data);
|
// request.fields['data'] = jsonEncode(data);
|
||||||
|
|
||||||
request.files
|
// request.files
|
||||||
.add(await http.MultipartFile.fromPath('photo', fotoProfil));
|
// .add(await http.MultipartFile.fromPath('photo', fotoProfil));
|
||||||
|
|
||||||
var streamResponse =
|
// var streamResponse =
|
||||||
await request.send().timeout(const Duration(seconds: 60));
|
// await request.send().timeout(const Duration(seconds: 60));
|
||||||
// var streamResponse = await request.send();
|
// // var streamResponse = await request.send();
|
||||||
var response = await http.Response.fromStream(streamResponse);
|
// var response = await http.Response.fromStream(streamResponse);
|
||||||
|
|
||||||
|
// var datanya = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var formData = FormData.fromMap({
|
||||||
|
'data': jsonEncode(data),
|
||||||
|
'photo': await MultipartFile.fromFile(fotoProfil),
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await dio.post(
|
||||||
|
'${globals.http_to_server}api/login/daftar1',
|
||||||
|
data: formData,
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
var datanya = response.data;
|
||||||
|
|
||||||
// final form = FormData({
|
// final form = FormData({
|
||||||
// 'photo': MultipartFile(File(fotoProfil).readAsBytesSync(),
|
// 'photo': MultipartFile(File(fotoProfil).readAsBytesSync(),
|
||||||
@ -137,8 +186,6 @@ class BeforeLoginApi extends GetxController {
|
|||||||
// final response =
|
// final response =
|
||||||
// await post('${globals.http_to_server}api/login/daftar1', form);
|
// await post('${globals.http_to_server}api/login/daftar1', form);
|
||||||
|
|
||||||
var datanya = jsonDecode(response.body);
|
|
||||||
|
|
||||||
log.i(response.statusCode.toString() + " ini status code");
|
log.i(response.statusCode.toString() + " ini status code");
|
||||||
log.i(datanya.toString());
|
log.i(datanya.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -212,14 +259,26 @@ class BeforeLoginApi extends GetxController {
|
|||||||
|
|
||||||
// var _response = await get(
|
// var _response = await get(
|
||||||
// '${globals.http_to_server}api/login?username=$username&password=$password&role=$role');
|
// '${globals.http_to_server}api/login?username=$username&password=$password&role=$role');
|
||||||
var uri = Uri.parse(
|
// var uri = Uri.parse(
|
||||||
'${globals.http_to_server}api/login?username=$username&password=$password&role=$role');
|
// '${globals.http_to_server}api/login?username=$username&password=$password&role=$role');
|
||||||
var _response = await http.get(uri, headers: {
|
// var _response = await http.get(uri, headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "crossDomain": "true",
|
||||||
|
// }).timeout(const Duration(seconds: 15));
|
||||||
|
|
||||||
|
// var _data = jsonDecode(_response.body);
|
||||||
|
|
||||||
|
var _response = await dio.get(
|
||||||
|
'${globals.http_to_server}api/login?username=$username&password=$password&role=$role',
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
"crossDomain": "true",
|
"crossDomain": "true",
|
||||||
}).timeout(const Duration(seconds: 15));
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
var _data = jsonDecode(_response.body);
|
var _data = _response.data;
|
||||||
|
|
||||||
log.i(_response.statusCode.toString() + " ini status code");
|
log.i(_response.statusCode.toString() + " ini status code");
|
||||||
log.i(_data['data']['_idnya'].toString() + " ini id");
|
log.i(_data['data']['_idnya'].toString() + " ini id");
|
||||||
@ -294,13 +353,25 @@ class BeforeLoginApi extends GetxController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response =
|
// var response =
|
||||||
await http.get(Uri.parse("${globals.http_to_server}api"), headers: {
|
// await http.get(Uri.parse("${globals.http_to_server}api"), headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
|
||||||
|
var response = await dio.get(
|
||||||
|
'${globals.http_to_server}api',
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
// final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = true;
|
result = true;
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
// ignore_for_file: file_names
|
// ignore_for_file: file_names
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
// import 'dart:convert';
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:get_storage/get_storage.dart';
|
import 'package:get_storage/get_storage.dart';
|
||||||
import 'package:http/http.dart' as http;
|
// import 'package:http/http.dart' as http;
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
|
|
||||||
@ -20,6 +21,13 @@ class KurirApi extends GetxController {
|
|||||||
static var password = storage.read("password");
|
static var password = storage.read("password");
|
||||||
static var id = storage.read("id");
|
static var id = storage.read("id");
|
||||||
|
|
||||||
|
static var options = BaseOptions(
|
||||||
|
// baseUrl: 'https://www.xx.com/api',
|
||||||
|
connectTimeout: 10000,
|
||||||
|
receiveTimeout: 10000,
|
||||||
|
);
|
||||||
|
Dio dio = Dio(options);
|
||||||
|
|
||||||
// get all pengiriman status ='Dalam Pengesahan Kurir'
|
// get all pengiriman status ='Dalam Pengesahan Kurir'
|
||||||
Future<Map<String, dynamic>> getAllPengirimanDalamPengesahanKurir() async {
|
Future<Map<String, dynamic>> getAllPengirimanDalamPengesahanKurir() async {
|
||||||
late Map<String, dynamic> result;
|
late Map<String, dynamic> result;
|
||||||
@ -33,16 +41,27 @@ class KurirApi extends GetxController {
|
|||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
|
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/pengiriman_kurir_dalam_pengesahan?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/pengiriman_kurir_dalam_pengesahan?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/kurir/pengiriman_kurir_dalam_pengesahan?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
},
|
||||||
final data = jsonDecode(response.body);
|
));
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -105,16 +124,27 @@ class KurirApi extends GetxController {
|
|||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
|
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/pengiriman_completed?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/pengiriman_completed?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/kurir/pengiriman_completed?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
},
|
||||||
final data = jsonDecode(response.body);
|
));
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -177,16 +207,27 @@ class KurirApi extends GetxController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/pengaturan?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/pengaturan?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/kurir/pengaturan?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
},
|
||||||
final data = jsonDecode(response.body);
|
));
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = {
|
result = {
|
||||||
'status': 200,
|
'status': 200,
|
||||||
@ -251,21 +292,38 @@ class KurirApi extends GetxController {
|
|||||||
status: 'Loading...',
|
status: 'Loading...',
|
||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
var response = await http.post(
|
// var response = await http.post(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/pengaturan?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/pengaturan?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// },
|
||||||
|
// body: {
|
||||||
|
// "minimal_biaya_pengiriman": minimalBiaya,
|
||||||
|
// "maksimal_biaya_pengiriman": maksimalBiaya,
|
||||||
|
// "biaya_per_kilo": biayaPerKilo
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
// final data = jsonDecode(response.body);
|
||||||
|
var response = await dio.post(
|
||||||
|
"${globals.http_to_server}api/kurir/pengaturan?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
},
|
},
|
||||||
body: {
|
),
|
||||||
|
data: {
|
||||||
"minimal_biaya_pengiriman": minimalBiaya,
|
"minimal_biaya_pengiriman": minimalBiaya,
|
||||||
"maksimal_biaya_pengiriman": maksimalBiaya,
|
"maksimal_biaya_pengiriman": maksimalBiaya,
|
||||||
"biaya_per_kilo": biayaPerKilo
|
"biaya_per_kilo": biayaPerKilo
|
||||||
}).timeout(const Duration(seconds: 10));
|
});
|
||||||
final data = jsonDecode(response.body);
|
final data = response.data;
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = {'status': 200, 'message': data['message'], 'data': data};
|
result = {'status': 200, 'message': data['message'], 'data': data};
|
||||||
} else {
|
} else {
|
||||||
@ -321,19 +379,32 @@ class KurirApi extends GetxController {
|
|||||||
|
|
||||||
if (_checkServer) {
|
if (_checkServer) {
|
||||||
try {
|
try {
|
||||||
var response = await http.post(
|
// var response = await http.post(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/sahkan_pengiriman?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/sahkan_pengiriman?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// },
|
||||||
|
// body: {
|
||||||
|
// "id_pengiriman": idPengiriman
|
||||||
|
// }).timeout(const Duration(seconds: 60));
|
||||||
|
// final data = jsonDecode(response.body);
|
||||||
|
var response = await dio.post(
|
||||||
|
"${globals.http_to_server}api/kurir/sahkan_pengiriman?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
},
|
},
|
||||||
body: {
|
),
|
||||||
"id_pengiriman": idPengiriman
|
data: {"id_pengiriman": idPengiriman});
|
||||||
}).timeout(const Duration(seconds: 60));
|
final data = response.data;
|
||||||
final data = jsonDecode(response.body);
|
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -394,16 +465,29 @@ class KurirApi extends GetxController {
|
|||||||
|
|
||||||
if (_checkServer) {
|
if (_checkServer) {
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/detail_pengiriman?username=$username&password=$password&id=$id&id_pengiriman=$idPengiriman"),
|
// "${globals.http_to_server}api/kurir/detail_pengiriman?username=$username&password=$password&id=$id&id_pengiriman=$idPengiriman"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 60));
|
||||||
|
// final data = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/kurir/detail_pengiriman?username=$username&password=$password&id=$id&id_pengiriman=$idPengiriman",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 60));
|
},
|
||||||
final data = jsonDecode(response.body);
|
));
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -465,19 +549,31 @@ class KurirApi extends GetxController {
|
|||||||
|
|
||||||
if (_checkServer) {
|
if (_checkServer) {
|
||||||
try {
|
try {
|
||||||
var response = await http.post(
|
// var response = await http.post(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/mengambil_paket_pengiriman?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/mengambil_paket_pengiriman?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// },
|
||||||
|
// body: {
|
||||||
|
// "id_pengiriman": idPengiriman
|
||||||
|
// }).timeout(const Duration(seconds: 60));
|
||||||
|
// final data = jsonDecode(response.body);
|
||||||
|
var response = await dio.post(
|
||||||
|
"${globals.http_to_server}api/kurir/mengambil_paket_pengiriman?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
},
|
},
|
||||||
body: {
|
),
|
||||||
"id_pengiriman": idPengiriman
|
data: {"id_pengiriman": idPengiriman});
|
||||||
}).timeout(const Duration(seconds: 60));
|
final data = response.data;
|
||||||
final data = jsonDecode(response.body);
|
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -543,13 +639,22 @@ class KurirApi extends GetxController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response =
|
// var response =
|
||||||
await http.get(Uri.parse("${globals.http_to_server}api"), headers: {
|
// await http.get(Uri.parse("${globals.http_to_server}api"), headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
var response = await dio.get("${globals.http_to_server}api",
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
},
|
||||||
|
));
|
||||||
// final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = true;
|
result = true;
|
||||||
@ -581,17 +686,28 @@ class KurirApi extends GetxController {
|
|||||||
|
|
||||||
if (_checkServer) {
|
if (_checkServer) {
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/kurir/profil_kurir?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/kurir/profil_kurir?username=$username&password=$password&id=$id"),
|
||||||
|
// headers: {
|
||||||
|
// "Accept": "application/json",
|
||||||
|
// // "authorization":
|
||||||
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
|
// "crossDomain": "true"
|
||||||
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
|
||||||
|
// final data = jsonDecode(response.body);
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/kurir/profil_kurir?username=$username&password=$password&id=$id",
|
||||||
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
// "authorization":
|
// "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
"crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
},
|
||||||
|
));
|
||||||
final data = jsonDecode(response.body);
|
final data = response.data;
|
||||||
dev.i(data);
|
dev.i(data);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = {
|
result = {
|
||||||
|
|||||||
@ -4,14 +4,15 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
// import 'package:get/get.dart';
|
||||||
import 'package:get_storage/get_storage.dart';
|
import 'package:get_storage/get_storage.dart';
|
||||||
import 'package:http/http.dart' as http;
|
// import 'package:http/http.dart' as http;
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
|
|
||||||
class PengirimApi extends GetxController {
|
class PengirimApi {
|
||||||
static var storage = GetStorage();
|
static var storage = GetStorage();
|
||||||
|
|
||||||
static var username = storage.read("username");
|
static var username = storage.read("username");
|
||||||
@ -20,6 +21,13 @@ class PengirimApi extends GetxController {
|
|||||||
|
|
||||||
final log = Logger();
|
final log = Logger();
|
||||||
|
|
||||||
|
static var options = BaseOptions(
|
||||||
|
// baseUrl: 'https://www.xx.com/api',
|
||||||
|
connectTimeout: 5000,
|
||||||
|
receiveTimeout: 5000,
|
||||||
|
);
|
||||||
|
Dio dio = Dio(options);
|
||||||
|
|
||||||
// get all kurir
|
// get all kurir
|
||||||
Future<Map<String, dynamic>> getAllKurir() async {
|
Future<Map<String, dynamic>> getAllKurir() async {
|
||||||
late Map<String, dynamic> result;
|
late Map<String, dynamic> result;
|
||||||
@ -32,16 +40,21 @@ class PengirimApi extends GetxController {
|
|||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/pengirim/kurir?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/pengirim/kurir?username=$username&password=$password&id=$id"),
|
||||||
headers: {
|
// headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
// "authorization":
|
// // "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
// "crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
// }).timeout(const Duration(seconds: 10));
|
||||||
final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/pengirim/kurir?username=$username&password=$password&id=$id");
|
||||||
|
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -113,16 +126,20 @@ class PengirimApi extends GetxController {
|
|||||||
status: 'Loading...',
|
status: 'Loading...',
|
||||||
maskType: EasyLoadingMaskType.black,
|
maskType: EasyLoadingMaskType.black,
|
||||||
);
|
);
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/pengirim/kurir/nama?nama=$nama&username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/pengirim/kurir/nama?nama=$nama&username=$username&password=$password&id=$id"),
|
||||||
headers: {
|
// headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
// "authorization":
|
// // "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
// "crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
// }).timeout(const Duration(seconds: 10));
|
||||||
final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/pengirim/kurir/nama?nama=$nama&username=$username&password=$password&id=$id");
|
||||||
|
var data = response.data;
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -199,16 +216,20 @@ class PengirimApi extends GetxController {
|
|||||||
String _biayaMaksimal = biayaMaksimal?.toString() ?? "";
|
String _biayaMaksimal = biayaMaksimal?.toString() ?? "";
|
||||||
String _biayaPerKm = biayaPerKm?.toString() ?? "";
|
String _biayaPerKm = biayaPerKm?.toString() ?? "";
|
||||||
|
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/pengirim/kurir/filter?nama=$_nama&biaya_maksimal=$_biayaMaksimal&biaya_per_km=$_biayaPerKm&username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/pengirim/kurir/filter?nama=$_nama&biaya_maksimal=$_biayaMaksimal&biaya_per_km=$_biayaPerKm&username=$username&password=$password&id=$id"),
|
||||||
headers: {
|
// headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
// "authorization":
|
// // "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
// "crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
// }).timeout(const Duration(seconds: 10));
|
||||||
final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/pengirim/kurir/filter?nama=$_nama&biaya_maksimal=$_biayaMaksimal&biaya_per_km=$_biayaPerKm&username=$username&password=$password&id=$id");
|
||||||
|
var data = response.data;
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
// log("ini status : " + response.statusCode.toString());
|
// log("ini status : " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -285,18 +306,28 @@ class PengirimApi extends GetxController {
|
|||||||
// log(foto_path.toString() + " ini datanya di pengiriman barang");
|
// log(foto_path.toString() + " ini datanya di pengiriman barang");
|
||||||
// remove foto_path from _datanya
|
// remove foto_path from _datanya
|
||||||
_datanya.remove('foto_path');
|
_datanya.remove('foto_path');
|
||||||
var postUri = Uri.parse(
|
// var postUri = Uri.parse(
|
||||||
'${globals.http_to_server}api/pengirim/pengiriman_barang?username=$username&password=$password&id=$id');
|
// '${globals.http_to_server}api/pengirim/pengiriman_barang?username=$username&password=$password&id=$id');
|
||||||
var request = http.MultipartRequest("POST", postUri);
|
// var request = http.MultipartRequest("POST", postUri);
|
||||||
request.fields['data'] = jsonEncode(_datanya);
|
// request.fields['data'] = jsonEncode(_datanya);
|
||||||
request.files.add(
|
// request.files.add(
|
||||||
await http.MultipartFile.fromPath('foto_pengiriman', foto_path));
|
// await http.MultipartFile.fromPath('foto_pengiriman', foto_path));
|
||||||
var streamResponse =
|
// var streamResponse =
|
||||||
await request.send().timeout(const Duration(seconds: 60));
|
// await request.send().timeout(const Duration(seconds: 60));
|
||||||
// var streamResponse = await request.send();
|
// // var streamResponse = await request.send();
|
||||||
var response = await http.Response.fromStream(streamResponse);
|
// var response = await http.Response.fromStream(streamResponse);
|
||||||
|
|
||||||
var datanya = jsonDecode(response.body);
|
// var datanya = jsonDecode(response.body);
|
||||||
|
var formData = FormData.fromMap({
|
||||||
|
"data": jsonEncode(_datanya),
|
||||||
|
"foto_pengiriman": await MultipartFile.fromFile(foto_path),
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await dio.post(
|
||||||
|
"${globals.http_to_server}api/pengirim/pengiriman_barang?username=$username&password=$password&id=$id",
|
||||||
|
data: formData);
|
||||||
|
|
||||||
|
var datanya = response.data;
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'status': 200,
|
'status': 200,
|
||||||
@ -353,16 +384,21 @@ class PengirimApi extends GetxController {
|
|||||||
|
|
||||||
if (_checkServer) {
|
if (_checkServer) {
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"${globals.http_to_server}api/pengirim/log_kiriman?username=$username&password=$password&id=$id"),
|
// "${globals.http_to_server}api/pengirim/log_kiriman?username=$username&password=$password&id=$id"),
|
||||||
headers: {
|
// headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
// "authorization":
|
// // "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
// "crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
// }).timeout(const Duration(seconds: 10));
|
||||||
final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var response = await dio.get(
|
||||||
|
"${globals.http_to_server}api/pengirim/log_kiriman?username=$username&password=$password&id=$id");
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
// log(data.toString());
|
// log(data.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = {
|
result = {
|
||||||
@ -421,18 +457,22 @@ class PengirimApi extends GetxController {
|
|||||||
double jarak = 0;
|
double jarak = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = await http.get(
|
// var response = await http.get(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"https://maps.googleapis.com/maps/api/directions/json?origin=$lat1,$lng1&destination=$lat2,$lng2&key=${globals.api_key}"),
|
// "https://maps.googleapis.com/maps/api/directions/json?origin=$lat1,$lng1&destination=$lat2,$lng2&key=${globals.api_key}"),
|
||||||
headers: {
|
// headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
// "authorization":
|
// // "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
// "crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
|
||||||
// log()
|
// log()
|
||||||
final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
|
|
||||||
|
var response = await dio.get(
|
||||||
|
"https://maps.googleapis.com/maps/api/directions/json?origin=$lat1,$lng1&destination=$lat2,$lng2&key=${globals.api_key}");
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
if (data["routes"].length > 0) {
|
if (data["routes"].length > 0) {
|
||||||
jarak = data["routes"][0]["legs"][0]["distance"]["value"] / 1000;
|
jarak = data["routes"][0]["legs"][0]["distance"]["value"] / 1000;
|
||||||
@ -457,13 +497,15 @@ class PengirimApi extends GetxController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response =
|
// var response =
|
||||||
await http.get(Uri.parse("${globals.http_to_server}api"), headers: {
|
// await http.get(Uri.parse("${globals.http_to_server}api"), headers: {
|
||||||
"Accept": "application/json",
|
// "Accept": "application/json",
|
||||||
// "authorization":
|
// // "authorization":
|
||||||
// "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
// // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}",
|
||||||
"crossDomain": "true"
|
// "crossDomain": "true"
|
||||||
}).timeout(const Duration(seconds: 10));
|
// }).timeout(const Duration(seconds: 10));
|
||||||
|
|
||||||
|
var response = await dio.get("${globals.http_to_server}api");
|
||||||
// final data = jsonDecode(response.body);
|
// final data = jsonDecode(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
result = true;
|
result = true;
|
||||||
|
|||||||
@ -201,7 +201,9 @@ class ProgressPenghantaranControllerKurir extends GetxController {
|
|||||||
|
|
||||||
Future<void> onQRViewCreated(BuildContext context, String aksinya) async {
|
Future<void> onQRViewCreated(BuildContext context, String aksinya) async {
|
||||||
Get.dialog(
|
Get.dialog(
|
||||||
QRcodeScannerWidget(),
|
QRcodeScannerWidget(
|
||||||
|
title: aksinya,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,8 +211,11 @@ class ProgressPenghantaranControllerKurir extends GetxController {
|
|||||||
class QRcodeScannerWidget extends StatefulWidget {
|
class QRcodeScannerWidget extends StatefulWidget {
|
||||||
const QRcodeScannerWidget({
|
const QRcodeScannerWidget({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.title,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<QRcodeScannerWidget> createState() => _QRcodeScannerWidgetState();
|
State<QRcodeScannerWidget> createState() => _QRcodeScannerWidgetState();
|
||||||
}
|
}
|
||||||
@ -225,8 +230,8 @@ class _QRcodeScannerWidgetState extends State<QRcodeScannerWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
backgroundColor: Color.fromARGB(255, 199, 214, 234),
|
backgroundColor: const Color.fromARGB(255, 199, 214, 234),
|
||||||
title: const Text("Scan QRCode"),
|
title: Text("Scan QRCode ${widget.title}"),
|
||||||
content: SizedBox(
|
content: SizedBox(
|
||||||
width: 250, // custom wrap size
|
width: 250, // custom wrap size
|
||||||
height: 250,
|
height: 250,
|
||||||
@ -243,17 +248,7 @@ class _QRcodeScannerWidgetState extends State<QRcodeScannerWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isScanning = false;
|
_isScanning = false;
|
||||||
});
|
});
|
||||||
Get.snackbar(
|
dev.i("scanner berhasil");
|
||||||
"Success",
|
|
||||||
"QRCode berhasil ditambahkan",
|
|
||||||
snackPosition: SnackPosition.TOP,
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
borderRadius: 10,
|
|
||||||
margin: EdgeInsets.all(10),
|
|
||||||
borderColor: Colors.green,
|
|
||||||
borderWidth: 2,
|
|
||||||
duration: Duration(seconds: 2),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isScanning = false;
|
_isScanning = false;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ void main() async {
|
|||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
// await initializeService();
|
// await initializeService();
|
||||||
// await Executor().warmUp(log: true);
|
// await Executor().warmUp(log: true);
|
||||||
HttpOverrides.global = MyHttpOverrides();
|
// HttpOverrides.global = MyHttpOverrides();
|
||||||
await GetStorage.init();
|
await GetStorage.init();
|
||||||
await _configureLocalTimeZone();
|
await _configureLocalTimeZone();
|
||||||
// await Firebase.initializeApp(
|
// await Firebase.initializeApp(
|
||||||
|
|||||||
@ -68,8 +68,7 @@ class _MainWidget extends StatelessWidget {
|
|||||||
if (controller.loadPengiriman.value == 1 &&
|
if (controller.loadPengiriman.value == 1 &&
|
||||||
controller.pengirimanModelList.isEmpty)
|
controller.pengirimanModelList.isEmpty)
|
||||||
const Center(
|
const Center(
|
||||||
child: TiadaDataWIdget(
|
child: TiadaDataWIdget(text: "Tiada log history pengiriman")),
|
||||||
text: "Tiada data pengiriman\ndalam proses pengesahan")),
|
|
||||||
if (controller.loadPengiriman.value == 2)
|
if (controller.loadPengiriman.value == 2)
|
||||||
const ErrorLoadDataWidget(),
|
const ErrorLoadDataWidget(),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class TiadaDataWIdget extends StatelessWidget {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
|
|||||||
16
pubspec.lock
16
pubspec.lock
@ -120,6 +120,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.1"
|
||||||
|
dio:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: dio
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.6"
|
||||||
double_back_to_close_app:
|
double_back_to_close_app:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -188,13 +195,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
flutter_barcode_scanner:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_barcode_scanner
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0"
|
|
||||||
flutter_easyloading:
|
flutter_easyloading:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -304,7 +304,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.7"
|
version: "2.1.7"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
|||||||
@ -39,7 +39,7 @@ dependencies:
|
|||||||
double_back_to_close_app: ^2.0.1
|
double_back_to_close_app: ^2.0.1
|
||||||
image_picker: ^0.8.5
|
image_picker: ^0.8.5
|
||||||
path_provider: ^2.0.9
|
path_provider: ^2.0.9
|
||||||
http: ^0.13.4
|
# http: ^0.13.4
|
||||||
flutter_easyloading: ^3.0.3
|
flutter_easyloading: ^3.0.3
|
||||||
crypto: ^3.0.1
|
crypto: ^3.0.1
|
||||||
provider: ^6.0.2
|
provider: ^6.0.2
|
||||||
@ -66,9 +66,11 @@ dependencies:
|
|||||||
enhance_stepper: ^0.1.1
|
enhance_stepper: ^0.1.1
|
||||||
logger: ^1.1.0
|
logger: ^1.1.0
|
||||||
# qr_code_scanner: ^0.7.0
|
# qr_code_scanner: ^0.7.0
|
||||||
flutter_barcode_scanner: ^2.0.0
|
# flutter_barcode_scanner: ^2.0.0
|
||||||
scan: ^1.6.0
|
scan: ^1.6.0
|
||||||
qr_flutter: ^4.0.0
|
qr_flutter: ^4.0.0
|
||||||
|
dio: ^4.0.6
|
||||||
|
|
||||||
|
|
||||||
# flutter_background_service_platform_interface: ^0.0.1
|
# flutter_background_service_platform_interface: ^0.0.1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user