mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-24 07:38:16 +02:00
feat: add mobile settings tab with player and content filter options, a new mobile scaffold, and logo asset.
This commit is contained in:
1 parent
4e00cc7dc7
commit
7e836f8ad3
8 files changed
+287
-121
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class IpService {
|
||||
static final IpService _instance = IpService._internal();
|
||||
|
||||
factory IpService() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
IpService._internal();
|
||||
|
||||
String? _cachedCountry;
|
||||
String? _cachedCountryCode;
|
||||
|
||||
Future<void> fetchIpDetails() async {
|
||||
if (_cachedCountry != null) return;
|
||||
|
||||
try {
|
||||
// Using ip-api.com (free tier, HTTP)
|
||||
final response = await http.get(Uri.parse('http://ip-api.com/json'));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = json.decode(response.body);
|
||||
if (data['status'] == 'success') {
|
||||
_cachedCountry = data['country'];
|
||||
_cachedCountryCode = data['countryCode'];
|
||||
debugPrint(
|
||||
'IpService: Detected country: $_cachedCountry ($_cachedCountryCode)');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('IpService: Error fetching IP details: $e');
|
||||
}
|
||||
}
|
||||
|
||||
String? get country => _cachedCountry;
|
||||
String? get countryCode => _cachedCountryCode;
|
||||
}
|
||||
Reference in new issue
Block a user