complete all
This commit is contained in:
3
.env
3
.env
@ -1,2 +1 @@
|
||||
SERVER_URL = http://192.168.189.237/absensi_server/apiuser/
|
||||
URL=http://192.168.189.237/absensi_server/
|
||||
URL=http://192.168.189.237:9000/
|
||||
BIN
assets/myfoto.jpg
Normal file
BIN
assets/myfoto.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
assets/tapak_tangan1.png
Normal file
BIN
assets/tapak_tangan1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
@ -1,9 +1,14 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:cek_tapak_tangan/src/config/theme.dart';
|
||||
import 'package:animated_snack_bar/animated_snack_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
import '../config/theme.dart';
|
||||
import '../services/api_service.dart';
|
||||
|
||||
class AmbilFoto extends StatefulWidget {
|
||||
const AmbilFoto({Key? key}) : super(key: key);
|
||||
@ -13,16 +18,25 @@ class AmbilFoto extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AmbilFotoState extends State<AmbilFoto> {
|
||||
final dev = Logger();
|
||||
bool _hasFoto = false; // if has foto
|
||||
String? _imgPath; // path to foto
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
XFile? _imageFile; // file to foto
|
||||
Uint8List? imagebytes;
|
||||
String? ramalannya;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// _picker
|
||||
}
|
||||
|
||||
Future<void> onImageButtonPressed() async {
|
||||
try {
|
||||
final XFile? pickedFile =
|
||||
await _picker.pickImage(source: ImageSource.camera);
|
||||
// _picker.
|
||||
final XFile? pickedFile = await _picker.pickImage(
|
||||
source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
|
||||
_imageFile = pickedFile;
|
||||
|
||||
final file = File(_imageFile!.path);
|
||||
@ -33,14 +47,152 @@ class _AmbilFotoState extends State<AmbilFoto> {
|
||||
imagebytes = bytes;
|
||||
_hasFoto = true;
|
||||
});
|
||||
// popDialog();
|
||||
// _showTambahLaporan();
|
||||
}
|
||||
await EasyLoading.show(
|
||||
status: "Periksa Foto",
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
Map? cekFoto = await ApiServices.cekFoto(_imgPath);
|
||||
await EasyLoading.dismiss();
|
||||
// dev.i(cekFoto);
|
||||
if (cekFoto!['status'] == 500) return mySnackBar(cekFoto['message'], 1);
|
||||
if (cekFoto['status'] == 404) return mySnackBar(cekFoto['message'], 2);
|
||||
await EasyLoading.show(
|
||||
status: "Meramal Masa Depan Dari Telapak Tangan Kiri Anda",
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
setState(() {
|
||||
ramalannya = null;
|
||||
});
|
||||
|
||||
Map? cekRamalan = await ApiServices.cekRamalan(_imgPath);
|
||||
await EasyLoading.dismiss();
|
||||
// dev.i(cekFoto);
|
||||
if (cekRamalan!['status'] == 500) {
|
||||
return mySnackBar(cekRamalan['message'], 1);
|
||||
}
|
||||
if (cekRamalan['status'] == 404) {
|
||||
return mySnackBar(cekRamalan['message'], 2);
|
||||
}
|
||||
setState(() {
|
||||
ramalannya = cekRamalan['message'];
|
||||
});
|
||||
await EasyLoading.dismiss();
|
||||
|
||||
dialogBoxRamalan();
|
||||
// dev.i("jalankan");
|
||||
} catch (e) {
|
||||
// dev.e(e);
|
||||
dev.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
void mySnackBar(String message, int stat) {
|
||||
const title = {
|
||||
1: "Error",
|
||||
2: "Warning",
|
||||
};
|
||||
|
||||
const type = {
|
||||
1: AnimatedSnackBarType.error,
|
||||
2: AnimatedSnackBarType.warning,
|
||||
};
|
||||
|
||||
AnimatedSnackBar.rectangle(
|
||||
title[stat]!,
|
||||
message,
|
||||
type: type[stat]!,
|
||||
brightness: Brightness.dark,
|
||||
).show(
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
popDialog() {
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
}
|
||||
|
||||
void dialogBoxRamalan() async {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content:
|
||||
RamalanAlertDialog(imagebytes: imagebytes, ramalan: ramalannya),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> dialogBox() async {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Center(
|
||||
child: Text(
|
||||
"Info",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 250,
|
||||
width: 200,
|
||||
// color: ThemeInfo.primary,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: ThemeInfo.primary,
|
||||
image: const DecorationImage(
|
||||
image: AssetImage('assets/tapak_tangan.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
// chil
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text(
|
||||
"Silakan ambil foto telapak tangan kiri anda seperti gambar diatas",
|
||||
textAlign: TextAlign.justify,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
popDialog();
|
||||
onImageButtonPressed();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ThemeInfo.primary,
|
||||
),
|
||||
child: const Text("Buka Camera"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -53,7 +205,7 @@ class _AmbilFotoState extends State<AmbilFoto> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
const Text(
|
||||
"Silakan Ambil Foto Telapak Anda",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
@ -63,7 +215,7 @@ class _AmbilFotoState extends State<AmbilFoto> {
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
ElevatedButton(
|
||||
@ -71,9 +223,10 @@ class _AmbilFotoState extends State<AmbilFoto> {
|
||||
backgroundColor: ThemeInfo.primary,
|
||||
),
|
||||
onPressed: () {
|
||||
onImageButtonPressed();
|
||||
// onImageButtonPressed();
|
||||
dialogBox();
|
||||
},
|
||||
child: Text(
|
||||
child: const Text(
|
||||
"Gambar Telapak Tangan",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
@ -87,3 +240,81 @@ class _AmbilFotoState extends State<AmbilFoto> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RamalanAlertDialog extends StatelessWidget {
|
||||
const RamalanAlertDialog({
|
||||
Key? key,
|
||||
Uint8List? imagebytes,
|
||||
String? ramalan,
|
||||
}) : _imagebytes = imagebytes,
|
||||
_ramalan = ramalan,
|
||||
super(key: key);
|
||||
|
||||
final Uint8List? _imagebytes;
|
||||
final String? _ramalan;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Center(
|
||||
child: Text(
|
||||
"Ramalan Telapak Tangan",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 250,
|
||||
width: 200,
|
||||
// color: ThemeInfo.primary,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: ThemeInfo.primary,
|
||||
image: DecorationImage(
|
||||
image: MemoryImage(_imagebytes!),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
// chil
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
_ramalan ?? "... Sedang Meramal Telapak Tangan Anda ...",
|
||||
textAlign: TextAlign.justify,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ThemeInfo.primary,
|
||||
),
|
||||
child: const Text("Ramal Lagi"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,133 +1,42 @@
|
||||
import 'package:cek_tapak_tangan/src/widgets/bounce_scoller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../config/theme.dart';
|
||||
|
||||
class ListPage extends StatelessWidget {
|
||||
const ListPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: BounceScrollerWidget(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
alignment: Alignment.center,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: ThemeInfo.myGrey,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: ThemeInfo.myGrey,
|
||||
blurRadius: 10,
|
||||
spreadRadius: 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"tanggal",
|
||||
style: const TextStyle(
|
||||
color: ThemeInfo.negroTexto,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"asdasd",
|
||||
style: const TextStyle(
|
||||
color: ThemeInfo.negroTexto,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'',
|
||||
style: const TextStyle(
|
||||
color: ThemeInfo.negroTexto,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
// lorem ipsum dolor sit amet consectetur adipisicing elit.
|
||||
'',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: const TextStyle(
|
||||
color: ThemeInfo.negroTexto,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: const BoxDecoration(
|
||||
color: ThemeInfo.primary,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: ThemeInfo.myGrey,
|
||||
blurRadius: 10,
|
||||
spreadRadius: 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
// dev.i("heheheh");
|
||||
// showLaporan(context);
|
||||
},
|
||||
icon: const Icon(Icons.read_more_outlined),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
body: SingleChildScrollView(
|
||||
child: BounceScrollerWidget(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: Image.asset(
|
||||
'assets/tapak_tangan1.png',
|
||||
width: 300,
|
||||
height: 300,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
" Ada 4 garis pokok yang terdapat pada telapak tangan kiri. Keempat garis utama itu ialah: A. garis kehidupan, B. Garis nasib , C. garis pikiran , D. garis cinta.\n Garis kehidupan bukan menunjukkan berapa panjang umur seseorang. Tapi menunjukkan kualitas kehidupan yang dijalani. Menunjukkan berapa banyak vitalitas, kekuatan dan energi yang dimiliki. Memberikan gambaran peristiwa apa yang bakal terjadi dalam hiduo orang tersebut dari kecil hingga dewasa, bahkan sampai usia senja\n Garis nasib menceritakan bagaimana kisah hidup anda berlangsung. Tapi garis nasib lebih menceritakan bagaimana potensi dan kehidupan sosial anda.\n Garis pikiran mereflesikan pikiran pemiliknya.Bagaimana kepribadian dan sikap seseorang terhadapa apa yang disukai atau dikerjakan\n Garis cinta mencerminkan kisah cinta, keberuntungan dalam asmara, bahkan kisah cinta dengan selingkuhan.",
|
||||
textAlign: TextAlign.justify,
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ class _ProfilPageState extends State<ProfilPage> {
|
||||
width: 100,
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.white,
|
||||
color: ThemeInfo.primary,
|
||||
// borderRadius: BorderRadius.circular(100),
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/loading.gif'),
|
||||
@ -42,23 +42,28 @@ class _ProfilPageState extends State<ProfilPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Image.asset(
|
||||
'assets/profile_blank.png',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
"asdsadsa",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ThemeInfo.negroTexto,
|
||||
child: Center(
|
||||
child: CircleAvatar(
|
||||
radius: 100,
|
||||
backgroundImage: AssetImage('assets/myfoto.jpg'),
|
||||
onBackgroundImageError: (exception, stackTrace) {
|
||||
return;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
_DetailParent(),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text(
|
||||
"Riskayani",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ThemeInfo.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const _DetailParent(),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -75,14 +80,24 @@ class _DetailParent extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_DetailChild(
|
||||
icon: Icons.person_pin,
|
||||
const _DetailChild(
|
||||
icon: Icons.list,
|
||||
title: "217 280 201",
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.1,
|
||||
)
|
||||
const _DetailChild(
|
||||
icon: Icons.person_pin,
|
||||
title: "Ade Hastuty, S.T ., S.Kom ., M.T",
|
||||
),
|
||||
const _DetailChild(
|
||||
icon: Icons.person_pin,
|
||||
title: "Hj. A. Irmayani P, S.T ., M.T",
|
||||
),
|
||||
const _DetailChild(
|
||||
icon: Icons.book_outlined,
|
||||
title: "Aplikasi Membaca Garis Tangan Berbasis Android",
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -112,7 +127,7 @@ class _DetailChild extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: ThemeInfo.myGrey,
|
||||
color: ThemeInfo.primary,
|
||||
size: 40,
|
||||
),
|
||||
const SizedBox(
|
||||
@ -127,7 +142,7 @@ class _DetailChild extends StatelessWidget {
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ThemeInfo.myGrey,
|
||||
color: ThemeInfo.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import 'package:cek_tapak_tangan/src/config/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../services/other_services.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
|
||||
@ -14,13 +16,18 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
super.initState();
|
||||
// initPlatformState();
|
||||
// future 3 sec
|
||||
|
||||
Future.delayed(const Duration(seconds: 4), () async {
|
||||
// await _storage.remove('userData');
|
||||
|
||||
Navigator.pushReplacementNamed(context, 'index');
|
||||
await OtherServices.cekAndDelete();
|
||||
goToIndex();
|
||||
});
|
||||
}
|
||||
|
||||
goToIndex() {
|
||||
Navigator.pushReplacementNamed(context, 'index');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -38,7 +45,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
top: MediaQuery.of(context).size.height * 0.1,
|
||||
left: MediaQuery.of(context).size.width * 0.1,
|
||||
right: MediaQuery.of(context).size.width * 0.1,
|
||||
child: Center(
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"Ramalan \nTelapak Tangan",
|
||||
textAlign: TextAlign.center,
|
||||
@ -55,7 +62,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
bottom: MediaQuery.of(context).size.height * 0.05,
|
||||
left: MediaQuery.of(context).size.width * 0.1,
|
||||
right: MediaQuery.of(context).size.width * 0.1,
|
||||
child: Center(
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"Created By \nKicap Karan",
|
||||
textAlign: TextAlign.center,
|
||||
|
||||
@ -0,0 +1,100 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
class ApiServices {
|
||||
static final dev = Logger();
|
||||
static final url = dotenv.env['URL'];
|
||||
|
||||
static final options = BaseOptions(
|
||||
baseUrl: url!,
|
||||
connectTimeout: 5000,
|
||||
receiveTimeout: 5000,
|
||||
);
|
||||
|
||||
static Dio dio = Dio(options);
|
||||
|
||||
static Future<Map?> cekFoto(String? path) async {
|
||||
dev.i("ini url $url");
|
||||
if (path == null) return null;
|
||||
try {
|
||||
var formData = FormData.fromMap({
|
||||
'image': await MultipartFile.fromFile(
|
||||
path,
|
||||
filename: basename(path),
|
||||
contentType: MediaType('image', 'jpg'),
|
||||
),
|
||||
});
|
||||
var response = await dio.post('', data: formData);
|
||||
var data = response.data;
|
||||
dev.i(data);
|
||||
return {
|
||||
"status": 200,
|
||||
"message": data['message'],
|
||||
};
|
||||
} on DioError catch (e) {
|
||||
dev.e(e.response);
|
||||
// return "Tidak dapat terhubung ke database";
|
||||
if (e.response == null) {
|
||||
return {
|
||||
"status": 500,
|
||||
"message": "Tidak Dapat Terhubung Ke Database",
|
||||
};
|
||||
}
|
||||
if (e.response!.statusCode == 404) {
|
||||
return {
|
||||
"status": e.response!.statusCode,
|
||||
"message": e.response!.data['detail'],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
dev.e(e);
|
||||
return {
|
||||
"status": 500,
|
||||
"message": "Tidak Dapat Terhubung Ke Database",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map?> cekRamalan(String? name) async {
|
||||
if (name == null) return null;
|
||||
try {
|
||||
var formData = FormData.fromMap({
|
||||
'image': basename(name),
|
||||
});
|
||||
var response = await dio.post('ramalan', data: formData);
|
||||
var data = response.data;
|
||||
dev.i(data);
|
||||
return {
|
||||
"status": 200,
|
||||
"message": data['message'],
|
||||
// "message": "Ini ramalannya",
|
||||
};
|
||||
} on DioError catch (e) {
|
||||
dev.e(e.response);
|
||||
// return "Tidak dapat terhubung ke database";
|
||||
if (e.response == null) {
|
||||
return {
|
||||
"status": 500,
|
||||
"message": "Tidak Dapat Terhubung Ke Database",
|
||||
};
|
||||
}
|
||||
if (e.response!.statusCode == 404) {
|
||||
return {
|
||||
"status": e.response!.statusCode,
|
||||
"message": e.response!.data['detail'],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
dev.e(e);
|
||||
return {
|
||||
"status": 500,
|
||||
"message": "Tidak Dapat Terhubung Ke Database",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
lib/src/services/other_services.dart
Normal file
32
lib/src/services/other_services.dart
Normal file
@ -0,0 +1,32 @@
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class OtherServices {
|
||||
static final dev = Logger();
|
||||
static Future<void> cekAndDelete() async {
|
||||
final appStorage = await getTemporaryDirectory();
|
||||
// // if (appStorage.existsSync()) {
|
||||
final fileList = appStorage.listSync();
|
||||
dev.i("${fileList}ini file list");
|
||||
if (fileList.isNotEmpty) {
|
||||
dev.i("ada file");
|
||||
// print(fileList);
|
||||
for (var i = 0; i < fileList.length; i++) {
|
||||
final file = fileList[i];
|
||||
dev.i(file.path);
|
||||
if (file.toString().contains(".jpg") ||
|
||||
file.toString().contains(".png") ||
|
||||
file.toString().contains(".jpeg") ||
|
||||
file.toString().contains(".JPG") ||
|
||||
file.toString().contains(".PNG") ||
|
||||
file.toString().contains(".JPEG")) {
|
||||
dev.i("delete");
|
||||
await file.delete(recursive: true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dev.i("tidak ada file");
|
||||
// print(fileList);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
pubspec.lock
18
pubspec.lock
@ -1,6 +1,13 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
animated_snack_bar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: animated_snack_bar
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -64,6 +71,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
dio:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dio
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.6"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -164,7 +178,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.13.5"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
@ -262,7 +276,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
|
||||
@ -46,6 +46,10 @@ dependencies:
|
||||
flutter_dotenv:
|
||||
google_fonts: ^3.0.1
|
||||
logger:
|
||||
dio:
|
||||
http_parser:
|
||||
path:
|
||||
animated_snack_bar:
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
|
||||
Reference in New Issue
Block a user