[Bug]: `Geocoding(locale: ...)` has no effect – locale is not forwarded to `_fromPlatformCreationParams`

Đang mở Phù hợp với người mới
#324 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

@AmrWalidi đang làm issue này rồi.

Từ ngày 31/10/2026.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
92/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
dart, flutter
Lĩnh vực
backend-api-design, mobile

Hướng nghiên cứu

Bắt đầu từ constructor công khai Geocoding và factory _fromPlatformCreationParams của nó, nơi issue xác định là điểm locale bị loại bỏ. Kiểm tra cách factory truyền locale đến phần triển khai của nền tảng, sau đó chuyển tiếp đối số của constructor và xác minh rằng locale được chỉ định tường minh đến được phần triển khai đó. Hoàn tất khi locale tiếng Đức được báo cáo được sử dụng thay cho locale của thiết bị.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Please check the following before submitting a new issue.
Please select affected platform(s)
  • Android
  • iOS
Steps to reproduce
  1. Set the device language to something other than German (e.g. English).
  2. Create a Geocoding instance with an explicit locale: Geocoding(locale: const Locale('de', 'DE')).
  3. Call placemarkFromCoordinates for a location in Germany (e.g. 52.5163, 13.3777, Brandenburger Tor, Berlin).
  4. Inspect the returned Placemark, e.g. placemark.country.
Expected results

The placemarks are returned in the locale passed to the constructor (de_DE), e.g. country == 'Deutschland'.

Actual results

The locale passed to the constructor is ignored. The placemarks come back in the device locale, e.g. country == 'Germany'.

The cause is in the public Geocoding constructor: it accepts locale, but does not forward it to the private factory Geocoding._fromPlatformCreationParams, so the value never reaches the platform implementation.

Proposed fix – forward the parameter:

Geocoding({Locale? locale})
    : this._fromPlatformCreationParams(
        pi.GeocodingCreationParams(),
        locale: locale,
      );
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:geocoding/geocoding.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: _reverseGeocode,
            child: Text('Reverse geocode'),
          ),
        ),
      ),
    );
  }
}

Future<void> _reverseGeocode() async {
  final geocoding = Geocoding(locale: const Locale('de', 'DE'));
  final placemarks = await geocoding.placemarkFromCoordinates(52.5163, 13.3777);

  // Device language set to English:
  // Expected: "Deutschland"
  // Actual:   "Germany"
  debugPrint(placemarks.first.country);
}
Screenshots or video
Version

5.0.0

Flutter Doctor output
Doctor output

(Irrelevant)

Ngôn ngữ chính
Dart
Star
153
Fork
92
Merge trung bình
7 ngày 21 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Baseflow/flutter-geocoding

Tất cả issue của Baseflow/flutter-geocoding

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.