Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#324 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
92/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
dart, flutter

调研方向

从公开的 Geocoding 构造函数及其 factory _fromPlatformCreationParams 入手。Issue 指出 locale 正是在这里被丢弃的。检查 factory 如何将 locale 传递给平台实现,然后转发构造函数参数,并验证显式指定的 locale 能传到平台实现。确认使用报告中提到的德语 locale,而不是设备 locale 后,即可完成。

由索引模型根据 Issue 内容生成。

描述

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)

主要语言
Dart
星标
153
派生
92
平均合并
7 天 21 小时
30 天内合并 PR
3

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Baseflow/flutter-geocoding 的其他 Issue

查看 Baseflow/flutter-geocoding 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。