finish caleg, area and tim survei page

This commit is contained in:
kicap
2023-10-26 16:05:01 +08:00
parent 364bee3120
commit 85be29e7ce
24 changed files with 1100 additions and 228 deletions

View File

@ -1,7 +1,13 @@
import 'package:dio/dio.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:stacked_services/stacked_services.dart';
import '../app/app.locator.dart';
import '../app/app.logger.dart';
class MyHttpServices {
final _log = getLogger('MyHttpServices');
final _snackbarService = locator<SnackbarService>();
final _options = BaseOptions(
baseUrl: dotenv.env['api_url']!,
connectTimeout: const Duration(milliseconds: 60000),
@ -17,7 +23,16 @@ class MyHttpServices {
Future<Response> get(String path) async {
try {
return await _dio.get(path);
} on DioException {
} on DioException catch (e) {
String response = e.response != null
? e.response!.data['message'].toString()
: e.toString();
_log.e('ini errornya: $response');
_snackbarService.showSnackbar(
message: response,
title: 'Error',
duration: const Duration(milliseconds: 1000),
);
rethrow;
}
}
@ -25,7 +40,16 @@ class MyHttpServices {
Future<Response> postWithFormData(String path, FormData formData) async {
try {
return await _dio.post(path, data: formData);
} on DioException {
} on DioException catch (e) {
String response = e.response != null
? e.response!.data['message'].toString()
: e.toString();
// _log.e('ini errornya: $response');
_snackbarService.showSnackbar(
message: response,
title: 'Error',
duration: const Duration(milliseconds: 1000),
);
rethrow;
}
}
@ -33,7 +57,16 @@ class MyHttpServices {
Future<Response> delete(String path) async {
try {
return await _dio.delete(path);
} on DioException {
} on DioException catch (e) {
String response = e.response != null
? e.response!.data['message'].toString()
: e.toString();
// _log.e('ini errornya: $response');
_snackbarService.showSnackbar(
message: response,
title: 'Error',
duration: const Duration(milliseconds: 1000),
);
rethrow;
}
}

View File

@ -0,0 +1,10 @@
import 'package:intl/intl.dart';
class MyFunction {
String convertDateTime(String input) {
DateTime dateTime = DateTime.parse(input);
String formattedDateTime =
DateFormat('dd-MM-yyyy | hh.mm.ss a').format(dateTime);
return formattedDateTime;
}
}