first week launch

This commit is contained in:
Wowieee4
2026-04-22 20:57:19 +07:00
commit 65b87d3d9d
170 changed files with 7378 additions and 0 deletions
@@ -0,0 +1,28 @@
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart'; // Wajib import ini
class ApiService {
static String get baseUrl {
if (kIsWeb) {
// Jika di Chrome/Web, tembak localhost langsung
return 'http://localhost:8080/api';
} else {
// Jika di Emulator Android, tembak IP khusus 10.0.2.2
return 'http://10.0.2.2:8080/api';
}
}
final Dio _dio = Dio(BaseOptions(
baseUrl: baseUrl,
connectTimeout: const Duration(seconds: 5),
// Penting buat Web agar tidak kena error CORS di sisi Client
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
));
Future<Response> post(String path, Map<String, dynamic> data) async {
return await _dio.post(path, data: data);
}
}
@@ -0,0 +1,8 @@
abstract class Failure {
final String message;
Failure(this.message);
}
class ServerFailure extends Failure {
ServerFailure(super.message);
}
@@ -0,0 +1,17 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class SecureStorage {
final _storage = const FlutterSecureStorage();
Future<void> saveToken(String token) async {
await _storage.write(key: 'jwt_token', value: token);
}
Future<String?> getToken() async {
return await _storage.read(key: 'jwt_token');
}
Future<void> deleteToken() async {
await _storage.delete(key: 'jwt_token');
}
}