You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中url_launcher与google_map_location_picker版本冲突如何解决?

Flutter url_launcher 与 google_map_location_picker 版本冲突解决方案

冲突根因

两个包依赖的公共中间包plugin_platform_interface版本要求不兼容:

  • url_launcher 6.0.6 及以上版本要求plugin_platform_interface >= 2.0.0
  • google_map_location_picker 4.1.3 及以上版本依赖的旧版 geolocator 要求plugin_platform_interface >= 1.0.2 < 2.0.0
    二者版本范围无交集,导致版本求解失败。

方案1:依赖覆盖(临时快速解决)

在pubspec.yaml中新增dependency_overrides节点,强制指定公共依赖的版本,原有依赖配置无需修改:

dependencies:
  google_map_location_picker: ^4.1.7
  url_launcher: ^6.0.9

# 新增以下配置
dependency_overrides:
  plugin_platform_interface: ^2.0.0

该方案为兼容适配方案,绝大多数场景下功能可正常运行,若出现异常可切换其他方案。

方案2:降级 url_launcher 版本

将url_launcher降级到6.0.5版本,该版本无需依赖2.0.0+的plugin_platform_interface,可直接兼容:

dependencies:
  google_map_location_picker: ^4.1.7
  url_launcher: 6.0.5 # 去掉^符号固定版本,防止自动升级到不兼容版本

方案3:替换停更插件(长期最优方案)

google_map_location_picker已停止维护多年,后续会持续出现依赖兼容、新系统适配等问题,建议替换为仍在迭代维护的同类型位置选择插件,也可基于官方google_maps_flutter自行实现位置选择逻辑,从根源解决兼容问题。

内容的提问来源于stack exchange,提问作者Ahmed Wagdi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 17:36:02