Flutter pub get 失败并出现 intl 错误。

3

我的应用昨天还能运行,但今天在尝试运行pub get时出现了以下错误,请问我错在哪里?我已经尝试添加了intl: 0.17.0-nullsafety.2,但它没有起作用,谢谢。

编辑

将 intl: 0.17.0-nullsafety 更改为 intl: ^0.16.1 并没有改变任何内容。

错误信息

    flutter pub get
    Running "flutter pub get" in koygitsin...                       
    Because every version of date_time_picker depends on intl ^0.16.1 and temp_name depends on intl 0.17.0-nullsafety.2, date_time_picker is forbidden.
    
    So, because temp_name depends on date_time_picker ^1.0.1, version solving failed.
    pub get failed (1; So, because temp_name depends on date_time_picker ^1.0.1, version solving failed.)

exit code 1

pubspec yaml

dependencies:
  flutter:
    sdk: flutter
    


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.0
  font_awesome_flutter: ^8.10.0
  carousel_slider: ^2.3.1
  firebase_ml_vision: ^0.9.10
  firebase_core: ^0.5.1
  firebase_auth: ^0.18.3
  firebase_messaging: ^7.0.3
  firebase_database: ^4.3.0
  firebase_storage: ^5.0.1
  image_picker: ^0.6.7+12
  cloud_firestore: ^0.14.3
  item_selector: ^0.1.1
  flutter_staggered_animations: ^0.1.2
  modal_progress_hud: ^0.1.3
  convex_bottom_bar: ^2.6.0
 
  google_fonts: ^1.1.1
  animations: ^1.1.2
  path_provider: ^1.6.24
  auto_size_text_field: ^0.1.7
  intl: 0.17.0-nullsafety.2
  flutter_bloc: ^6.1.1
  flutter_picker: ^1.1.5
  date_time_picker: ^1.0.1
  sliding_up_panel: ^1.0.2
  flutter_onboard: ^0.1.0
  image_crop: ^0.3.4
  audioplayer: ^0.8.1
  flutter_countdown_timer: ^1.6.0
  shared_preferences: 0.5.12+4
  argon_buttons_flutter: ^1.0.6
  cached_network_image: ^2.4.1
  material_floating_search_bar: ^0.2.4
  flutter_neumorphic: ^3.0.3
3个回答

5
这是因为 date_time_picker 依赖于 intl ^0.16.1。
1.将以下内容添加到你的包的 pubspec.yaml 文件中:
dependency_overrides:
 intl: ^0.16.1` 

编辑:

或者

尝试将以下命令添加到pubspec.yaml文件中:

dependency_overrides:
 intl: any

2. 使用Flutter运行:

$ flutter pub get

3.在你的Dart代码中导入它,你可以使用:

import 'package:intl/intl.dart';

请问您能否尝试一下?dependency_overrides: intl: any - Pulsara Sandeepa
同样的操作再试一遍,删除这个库,然后应用程序就可以正常工作了。 - Emir Kutlugün
依赖覆盖: intl: any为我工作 - aflopezbec

1

将你的intl包版本更改为

intl ^0.16.1

在pubspec.yaml文件中,从以下版本更改:

intl: 0.17.0-nullsafety.2


-1

您的软件包版本不兼容,因此出现错误。请确保您的依赖项是最新版本。

https://pub.dev/


我之前尝试过更改为当前版本,但仍然出现相同的错误,忘记将此添加到问题中。 - Emir Kutlugün

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接