如何解决此问题错误:无法解析包?

问题描述 投票:0回答:4

我面临这个问题。我怎么解决这个问题。请帮助我。

Error: Couldn't resolve the package 'intl' in 'package:intl/intl.dart'.
lib/screens/chat.dart:4:8: Error: Not found: 'package:intl/intl.dart'
import 'package:intl/intl.dart';
       ^
lib/screens/chat.dart:98:13: Error: 'DateFormat' isn't a type.
      final DateFormat date_formatter = DateFormat('yyyy-MM-dd');
            ^^^^^^^^^^
lib/screens/chat.dart:99:13: Error: 'DateFormat' isn't a type.
      final DateFormat time_formatter = DateFormat('hh:ss');
            ^^^^^^^^^^
lib/screens/chat.dart:98:41: Error: The method 'DateFormat' isn't defined for the class '_
ChatState'.
 - '_ChatState' is from 'package:ecommerce_flutter/screens/chat.dart' ('lib/screens
/chat.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Dat
eFormat'.
      final DateFormat date_formatter = DateFormat('yyyy-MM-dd');
                                        ^^^^^^^^^^
lib/screens/chat.dart:99:41: Error: The method 'DateFormat' isn't defined for the class '_
ChatState'.
 - '_ChatState' is from 'package:ecommerce_flutter/screens/chat.dart' ('lib/screens
/chat.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Dat
eFormat'.
      final DateFormat time_formatter = DateFormat('hh:ss');
                                        ^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dar
t:83:7: Error: No named parameter with the name 'resizeToAvoidBottomPadding'.
      resizeToAvoidBottomPadding: false,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/scaffold.dart:1466:9: Context: Found thi
s candidate, but the arguments don't match.
  const Scaffold({
        ^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dar
t:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'Bu
ildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
ackages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inh
eritFromWidgetOfExactType'.
        context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie_audio-1.0.0+1/lib/src/chewie_pla
yer.dart:101:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the cl
ass 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
ackages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inh
eritFromWidgetOfExactType'.
        context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_prov
ider.dart:50:59: Error: No named parameter with the name 'nullOk'.
        context != null ? Localizations.localeOf(context, nullOk: true) : null,
                                                          ^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found
 this candidate, but the arguments don't match.
  static Locale localeOf(BuildContext context) {
                ^^^^^^^^
Unhandled exception:
FileSystemE
xception(uri=org-dartlang-untranslatable-uri:package%3Aintl%2Fintl.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_proto
type/standard_file_system.dart:36:7)
#1      asFileUri (package:vm/ker
nel_front_end.dart:599:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:738:21)
<asynchrono
us suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.
dart:562:9)
<asynchronous suspension>
#4      starter (package:flutter_fron
tend_server/server.dart:180:12)
<asynchronous suspension>
#5      main (file:///C:/b
/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:13:2
4)
<asynchronous suspension>

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to
get more log output. Run with --scan to get full insights.

C:\src\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19042.1052], locale en-US)
    • Flutter version 2.2.2 at C:\src\flutter
    • Framework revision d79295af24 (7 days ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\mehed\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] VS Code (version 1.57.0)
    • VS Code at C:\Users\mehed\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.23.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.101
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 91.0.864.48

• No issues found!
Process finished with exit code 0
android flutter gradle caching flutter-layout
4个回答
9
投票

1 个月后,我在 Equatable 上遇到了这个确切的问题。

有时你的缓存很脏,所以你需要清理:

网络上的每个解决方案都会告诉您:

flutter clean

然后

flutter pub get

我希望它对你有用。对我来说没有:(.


1
投票

看起来你还没有安装 dart 包:intl。 请在此处找到软件包链接:https://pub.dev/packages/intl/install

在项目的 pubspec.yaml 中添加以下依赖项:

dependencies:
  intl: ^0.17.0

有关详细信息,请查看此处的软件包安装说明:https://pub.dev/packages/intl/install


0
投票

package:intl/intl.dart
确保您的文件位于正确的位置


0
投票

对我来说,解决方案是使用

flutter pub upgrade

然后一切又按预期工作了...

© www.soinside.com 2019 - 2024. All rights reserved.