ADD ALOT OF POLISHING AND UPDATES...
This commit is contained in:
+17
-15
@@ -6,6 +6,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../app/injection_container.dart';
|
||||
import '../../core/constants/app_constants.dart';
|
||||
import '../../core/errors/friendly_error.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -37,21 +38,22 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
_ok = false;
|
||||
_message = null;
|
||||
});
|
||||
try {
|
||||
final clean = AppConstants.normalizeServerUrl(_url.text);
|
||||
final res = await Dio(BaseOptions(
|
||||
connectTimeout: AppConstants.pingTimeout,
|
||||
receiveTimeout: AppConstants.pingTimeout,
|
||||
)).get('$clean/api/v1/auth/ping');
|
||||
_ok = res.statusCode == 200 && res.data['success'] == true;
|
||||
_message = _ok
|
||||
? 'Server aktif dan siap dipakai.'
|
||||
: 'Server merespons dengan format tidak valid.';
|
||||
} catch (e) {
|
||||
_message = 'Tidak bisa terhubung. Periksa URL dan jaringan.';
|
||||
} finally {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
await runFriendlyAction(
|
||||
() async {
|
||||
final clean = AppConstants.normalizeServerUrl(_url.text);
|
||||
final res = await Dio(BaseOptions(
|
||||
connectTimeout: AppConstants.pingTimeout,
|
||||
receiveTimeout: AppConstants.pingTimeout,
|
||||
)).get('$clean/api/v1/auth/ping');
|
||||
_ok = res.statusCode == 200 && res.data['success'] == true;
|
||||
_message = _ok
|
||||
? 'Server aktif dan siap dipakai.'
|
||||
: 'Server merespons dengan format tidak valid.';
|
||||
},
|
||||
onError: (message) => _message = message,
|
||||
fallback: 'Tidak bisa terhubung. Periksa URL dan jaringan.',
|
||||
);
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
|
||||
Future<void> _continue() async {
|
||||
|
||||
Reference in New Issue
Block a user