Apply dart format to all files
This commit is contained in:
@@ -4,10 +4,15 @@ import '../config/api.dart';
|
||||
|
||||
class GeoService {
|
||||
final http.Client _client;
|
||||
|
||||
|
||||
GeoService({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
Future<void> updatePosition(String token, String id, double x, double y) async {
|
||||
Future<void> updatePosition(
|
||||
String token,
|
||||
String id,
|
||||
double x,
|
||||
double y,
|
||||
) async {
|
||||
final response = await _client.put(
|
||||
Uri.parse('${ApiConfig.geoUrl}?id=$id'),
|
||||
headers: {
|
||||
@@ -16,9 +21,9 @@ class GeoService {
|
||||
},
|
||||
body: jsonEncode({'x': x, 'y': y}),
|
||||
);
|
||||
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('Failed to update position');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,17 @@ import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
class PlatformService {
|
||||
bool get isWeb => kIsWeb;
|
||||
bool get isNative => !kIsWeb;
|
||||
String get platformName => isWeb ? 'web' : Platform.isAndroid ? 'android' : Platform.isIOS ? 'ios' : Platform.isWindows ? 'windows' : Platform.isMacOS ? 'macos' : Platform.isLinux ? 'linux' : 'unknown';
|
||||
String get platformName => isWeb
|
||||
? 'web'
|
||||
: Platform.isAndroid
|
||||
? 'android'
|
||||
: Platform.isIOS
|
||||
? 'ios'
|
||||
: Platform.isWindows
|
||||
? 'windows'
|
||||
: Platform.isMacOS
|
||||
? 'macos'
|
||||
: Platform.isLinux
|
||||
? 'linux'
|
||||
: 'unknown';
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SettingsService {
|
||||
static const String _baseUrlKey = 'server_base_url';
|
||||
static const String _defaultBaseUrl = 'https://family-safety.onrender.com/api';
|
||||
static const String _defaultBaseUrl =
|
||||
'https://family-safety.onrender.com/api';
|
||||
|
||||
String _baseUrl = _defaultBaseUrl;
|
||||
bool _initialized = false;
|
||||
|
||||
@@ -4,10 +4,14 @@ import '../config/api.dart';
|
||||
|
||||
class ShareService {
|
||||
final http.Client _client;
|
||||
|
||||
|
||||
ShareService({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
Future<Map<String, dynamic>> createShare(String token, double x, double y) async {
|
||||
Future<Map<String, dynamic>> createShare(
|
||||
String token,
|
||||
double x,
|
||||
double y,
|
||||
) async {
|
||||
final response = await _client.post(
|
||||
Uri.parse(ApiConfig.shareUrl),
|
||||
headers: {
|
||||
@@ -16,7 +20,7 @@ class ShareService {
|
||||
},
|
||||
body: jsonEncode({'x': x, 'y': y}),
|
||||
);
|
||||
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
try {
|
||||
final data = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
@@ -25,22 +29,29 @@ class ShareService {
|
||||
'share_id': data['share_id']?.toString() ?? '',
|
||||
};
|
||||
} catch (e) {
|
||||
throw Exception('Failed to parse response: $e | Body: ${response.body.substring(0, response.body.length > 200 ? 200 : response.body.length)}');
|
||||
throw Exception(
|
||||
'Failed to parse response: $e | Body: ${response.body.substring(0, response.body.length > 200 ? 200 : response.body.length)}',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
final errorBody = response.body.length > 200 ? response.body.substring(0, 200) : response.body;
|
||||
throw Exception('Failed to create share link: ${response.statusCode} - $errorBody');
|
||||
final errorBody = response.body.length > 200
|
||||
? response.body.substring(0, 200)
|
||||
: response.body;
|
||||
throw Exception(
|
||||
'Failed to create share link: ${response.statusCode} - $errorBody',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getPositionByShareId(String token, String shareId) async {
|
||||
Future<Map<String, dynamic>> getPositionByShareId(
|
||||
String token,
|
||||
String shareId,
|
||||
) async {
|
||||
final response = await _client.get(
|
||||
Uri.parse('${ApiConfig.watchUrl}?share_id=$shareId'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
);
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user