0812
This commit is contained in:
20
lib/services/location_service.dart
Normal file
20
lib/services/location_service.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'dart:convert';
|
||||
import 'package:basic_intl/intl.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class LocationService {
|
||||
String lang = Intl.getCurrentLocale().startsWith('zh') ? 'zh' : 'en';
|
||||
Future<String> search(double lon, double lat) async {
|
||||
try {
|
||||
final uri = Uri.parse(
|
||||
'http://143.64.185.20:18606/location_info?lon=${lon}&lat=${lat}&lang=${lang}');
|
||||
final response = await http.get(uri);
|
||||
if (response.statusCode == 200) {
|
||||
return json.decode(response.body)['address'];
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error during text classification: $e');
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user