finish caleg, area and tim survei page
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
10
lib/services/other_function.dart
Normal file
10
lib/services/other_function.dart
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user