check web and tablet for logic
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class NetworkConnectivity {
|
||||
static final NetworkConnectivity _instance = NetworkConnectivity._internal();
|
||||
factory NetworkConnectivity() => _instance;
|
||||
@@ -7,15 +9,19 @@ class NetworkConnectivity {
|
||||
|
||||
/// Check if device has internet connectivity
|
||||
Future<bool> hasInternetConnection() async {
|
||||
try {
|
||||
// Try to reach a reliable host to check internet connectivity
|
||||
final result = await InternetAddress.lookup('google.com');
|
||||
return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
|
||||
} on SocketException catch (_) {
|
||||
return false;
|
||||
} on Exception catch (_) {
|
||||
// If connectivity check fails, assume no connection
|
||||
return false;
|
||||
if (kIsWeb) {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
// Try to reach a reliable host to check internet connectivity
|
||||
final result = await InternetAddress.lookup('google.com');
|
||||
return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
|
||||
} on SocketException catch (_) {
|
||||
return false;
|
||||
} on Exception catch (_) {
|
||||
// If connectivity check fails, assume no connection
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../config/app_config.dart';
|
||||
import '../utils/logger.dart';
|
||||
import '../utils/result.dart';
|
||||
import 'app_exceptions.dart';
|
||||
@@ -16,7 +17,7 @@ class NetworkManager {
|
||||
NetworkManager()
|
||||
: mainDio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: 'http://10.0.2.2:8081',
|
||||
baseUrl: AppConfig.apiBaseUrl,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user