first commit
This commit is contained in:
3
lib/services/global_var.dart
Normal file
3
lib/services/global_var.dart
Normal file
@ -0,0 +1,3 @@
|
||||
class GlobalVar {
|
||||
String backPressed = 'backNormal';
|
||||
}
|
35
lib/services/http_services.dart
Normal file
35
lib/services/http_services.dart
Normal file
@ -0,0 +1,35 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
import '../app/app.logger.dart';
|
||||
|
||||
class MyHttpServices {
|
||||
final log = getLogger('MyHttpServices');
|
||||
final _options = BaseOptions(
|
||||
baseUrl: dotenv.env['api_url']!,
|
||||
connectTimeout: const Duration(seconds: 120),
|
||||
receiveTimeout: const Duration(seconds: 120),
|
||||
);
|
||||
|
||||
late Dio _dio;
|
||||
|
||||
MyHttpServices() {
|
||||
_dio = Dio(_options);
|
||||
}
|
||||
|
||||
Future<Response> get(String path) async {
|
||||
try {
|
||||
return await _dio.get(path);
|
||||
} on DioException {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> postWithFormData(String path, FormData formData) async {
|
||||
try {
|
||||
return await _dio.post(path, data: formData);
|
||||
} on DioException {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
39
lib/services/my_easyloading.dart
Normal file
39
lib/services/my_easyloading.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
|
||||
class MyEasyLoading {
|
||||
showLoading() {
|
||||
EasyLoading.show(
|
||||
status: 'loading...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
dismissOnTap: false,
|
||||
);
|
||||
}
|
||||
|
||||
dismissLoading() {
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
customLoading(String message) {
|
||||
EasyLoading.show(
|
||||
status: message,
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
dismissOnTap: false,
|
||||
);
|
||||
}
|
||||
|
||||
showSuccess(String message) {
|
||||
EasyLoading.showSuccess(message);
|
||||
}
|
||||
|
||||
showError(String message) {
|
||||
EasyLoading.showError(message);
|
||||
}
|
||||
|
||||
showInfo(String message) {
|
||||
EasyLoading.showInfo(message);
|
||||
}
|
||||
|
||||
showProgress(double progress, String status) {
|
||||
EasyLoading.showProgress(progress, status: status);
|
||||
}
|
||||
}
|
18
lib/services/other_function.dart
Normal file
18
lib/services/other_function.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class OtherFunction {
|
||||
int umur(String tanggalLahir) {
|
||||
// change tanggalLahir to DateTime
|
||||
DateTime date = DateTime.parse(tanggalLahir);
|
||||
// get current date
|
||||
DateTime now = DateTime.now();
|
||||
// get difference in year
|
||||
int year = now.year - date.year;
|
||||
return year;
|
||||
}
|
||||
|
||||
String commaFormat(int number) {
|
||||
final formatter = NumberFormat('#,###');
|
||||
return formatter.format(number);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user