Apply dart format to all files
This commit is contained in:
@@ -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