无法在Flutter SDK中找到flutter_localization包

k10s72fa  于 2022-11-17  发布在  Flutter
关注(0)|答案(2)|浏览(224)

我目前正尝试在Flutter应用程序中实现本地化,但每当我尝试为flutter_localization添加依赖项时,我都会收到以下错误消息:
由于计时器依赖于SDK中不存在的flutter_localization(无法在Flutter SDK中找到包flutter_localization),版本求解失败。
我还在Android Studio中正确地添加了flutter和dart SDK的路径。
下面是我的pubspec.yaml文件:

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: '>=2.18.2 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  intl: ^0.17.0-nullsafety.2
  cupertino_icons: ^1.0.2
  sqflite: any
  shared_preferences: ^2.0.15
  path_provider: any
  flutter_localization:
    sdk: flutter
  flutter_cupertino_localizations: ^1.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0

flutter:

  uses-material-design: true

没有flutter_localization,我无法访问GlobalMaterialLocalizations,显然,这是最简单的解决方案。我已经尝试了许多解决方案,如检查版本兼容性和更新所有依赖项。你们能帮我吗?
提前致谢!
升级SDK、升级依赖项、重新安装flutter和Dart等

5kgi1eie

5kgi1eie1#

您拼错了软件包
替换

flutter_localization:
    sdk: flutter

flutter_localizations:
    sdk: flutter

记录flutter_localization上的s

smtd7mpg

smtd7mpg2#

flutter:
  generate: true

将其添加到您的pubspec.yaml中,并按照本文中的说明using gen-l10 n部分进行操作
https://localizely.com/blog/flutter-localization-step-by-step/?tab=using-gen-l10n

相关问题