使用syncfusion_flutter_pdfviewer时添加flick_video_player的版本冲突解决咨询
问题:Flutter依赖版本冲突(syncfusion_flutter_pdfviewer与flick_video_player)
当前使用syncfusion_flutter_pdfviewer: ^22.2.10,添加flick_video_player时出现版本解析失败,报错信息如下:
The current Dart SDK version is 3.2.5. Because syncfusion_flutter_pdfviewer >=22.1.34 depends on device_info_plus ^9.0.2 which depends on win32 >=4.0.0 <6.0.0, syncfusion_flutter_pdfviewer >=22.1.34 requires win32 >=4.0.0 <6.0.0. Because wakelock_windows >=0.2.1 depends on win32 ^3.0.0 and wakelock_windows <0.2.1 depends on win32 ^2.0.0, every version of wakelock_windows requires win32 ^2.0.0 or ^3.0.0. (1) Thus, syncfusion_flutter_pdfviewer >=22.1.34 is incompatible with wakelock_windows. And because flick_video_player ^0.4.0 depends on wakelock ^0.5.6 and flick_video_player >=0.3.0 <0.4.0-dev.4 depends on wakelock ^0.5.0+2, flick_video_player <0.4.0-dev.4 or >=0.4.0 <0.6.0-∞ requires wakelock >=0.5.0+2 <0.6.0 or ^0.6.0. And because flick_video_player >=0.4.0-dev.4 <0.4.0 depends on wakelock ^0.5.0+3 and wakelock >=0.5.0 <0.5.6 depends on wakelock_windows ^0.1.0, flick_video_player <0.6.0 requires wakelock_windows ^0.1.0 or wakelock >=0.5.6 <0.6.0 or ^0.6.0. And because flick_video_player >=0.6.0 depends on wakelock ^0.6.2 which depends on wakelock_windows ^0.2.0, every version of flick_video_player requires wakelock_windows ^0.1.0 or ^0.2.0. And because syncfusion_flutter_pdfviewer >=22.1.34 is incompatible with wakelock_windows (1), syncfusion_flutter_pdfviewer >=22.1.34 is incompatible with flick_video_player. So, because innerlight depends on both syncfusion_flutter_pdfviewer ^22.2.10 and flick_video_player any, version solving failed. The lower bound of "sdk: '>=2.4.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.
解决方案
1. 升级flick_video_player到兼容win32 4.x的版本
检查flick_video_player的最新稳定版本,确认其是否已更新依赖的wakelock及wakelock_windows以支持win32 >=4.0.0。在pubspec.yaml中指定最新兼容版本:
flick_video_player: ^最新版本号
可通过执行flutter pub outdated查看可用升级版本,或查看包的版本变更日志确认兼容性。
2. 降级syncfusion_flutter_pdfviewer到22.1.33及以下版本
若暂时无法升级flick_video_player,可将syncfusion_flutter_pdfviewer降级到不依赖device_info_plus ^9.0.2的版本(即22.1.33及更早版本),修改pubspec.yaml:
syncfusion_flutter_pdfviewer: ^22.1.33
3. 使用dependency_overrides强制统一win32版本
在pubspec.yaml中添加依赖覆盖,强制所有依赖包使用兼容的win32版本(需测试兼容性,若wakelock_windows无法兼容4.x版本则此方案可能不可行):
dependency_overrides: win32: ^4.0.0
4. 修复SDK版本下限问题
根据报错提示,更新pubspec.yaml中的SDK约束,确保下限>=2.12.0以启用空安全:
environment: sdk: '>=3.2.5 <4.0.0' # 可根据当前Flutter SDK版本调整,确保下限不低于2.12.0
内容的提问来源于stack exchange,提问作者Mussadaq Ahmad Jamil
相关产品推荐
相关产品推荐

