import 'dart:convert';
import 'package:t_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 "";
  }
}
