[Bug]: `Geocoding(locale: ...)` has no effect – locale is not forwarded to `_fromPlatformCreationParams`
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 92/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
从公开的 Geocoding 构造函数及其 factory _fromPlatformCreationParams 入手。Issue 指出 locale 正是在这里被丢弃的。检查 factory 如何将 locale 传递给平台实现,然后转发构造函数参数,并验证显式指定的 locale 能传到平台实现。确认使用报告中提到的德语 locale,而不是设备 locale 后,即可完成。
由索引模型根据 Issue 内容生成。
描述
Please check the following before submitting a new issue.
- I have searched the existing issues.
- I have carefully read the documentation and verified I have added the required platform specific configuration.
Please select affected platform(s)
- Android
- iOS
Steps to reproduce
- Set the device language to something other than German (e.g. English).
- Create a
Geocodinginstance with an explicit locale:Geocoding(locale: const Locale('de', 'DE')). - Call
placemarkFromCoordinatesfor a location in Germany (e.g.52.5163, 13.3777, Brandenburger Tor, Berlin). - 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Baseflow/flutter-geocoding 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 84/100
Baseflow/flutter-geocoding#311 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
Baseflow/flutter-geocoding#309 ·
-
难度 4/5 3-5 天 新手友好度 49/100
Baseflow/flutter-geocoding#327 ·
-
难度 4/5 3-5 天 新手友好度 38/100
Baseflow/flutter-geocoding#287 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
Baseflow/flutter-geocoding#286 · 2 条评论 ·
查看 Baseflow/flutter-geocoding 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 4 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 69/100
维护者通常 3 天内回复
-
area-clientside-dartpad
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
'图片收藏'功能无法滑动未关闭
难度 2/5 1-3 小时 新手友好度 68/100
venera-app/venera-prime#50 ·