api update and flutter update
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppConstants {
|
||||
static const String _serverUrlKey = 'server_base_url';
|
||||
|
||||
// Ambil base URL dari SharedPreferences
|
||||
static Future<String?> getServerUrl() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getString(_serverUrlKey);
|
||||
}
|
||||
|
||||
// Simpan URL setelah berhasil connect
|
||||
static Future<void> setServerUrl(String url) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
// Trim trailing slash
|
||||
final cleaned = url.endsWith('/') ? url.substring(0, url.length - 1) : url;
|
||||
await prefs.setString(_serverUrlKey, cleaned);
|
||||
}
|
||||
|
||||
static Future<void> clearServerUrl() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove(_serverUrlKey);
|
||||
}
|
||||
|
||||
static String buildApiUrl(String baseUrl) => '$baseUrl/api/v1';
|
||||
static String buildWsUrl(String baseUrl) => baseUrl.replaceFirst('http', 'ws') + '/ws';
|
||||
|
||||
// Timeouts
|
||||
static const Duration connectTimeout = Duration(seconds: 10);
|
||||
static const Duration receiveTimeout = Duration(seconds: 30);
|
||||
static const Duration pingTimeout = Duration(seconds: 5);
|
||||
|
||||
// Location intervals
|
||||
static const int locationIntervalWalkMs = 5000;
|
||||
static const int locationIntervalIdleMs = 30000;
|
||||
|
||||
// YOLO
|
||||
static const String yoloModelPath = 'assets/models/yolov8n.tflite';
|
||||
static const String yoloLabelsPath = 'assets/models/labels.txt';
|
||||
static const int yoloInputSize = 640;
|
||||
|
||||
// Agora - ganti dengan App ID dari agora.io
|
||||
static const String agoraAppId = 'YOUR_AGORA_APP_ID';
|
||||
}
|
||||
Reference in New Issue
Block a user