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

hwazgwia  于 2022-11-14  发布在  其他
关注(0)|答案(5)|浏览(175)

我面临着这个问题。我怎样才能解决这个问题。请帮助我。

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
vpfxa7rd

vpfxa7rd1#

1个月后,我有这个精确的问题与Equatable。
有时候,您的缓存是脏的,因此您需要清理:
我们会告诉您每一个解决方案:

flutter clean

然后

flutter pub get

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

bwntbbo3

bwntbbo32#

您似乎尚未安装dart套件:intl。请在此处找到软件包链接:https://pub.dev/packages/intl/install
在项目的pubspec.yaml中添加以下依赖项:

dependencies:
  intl: ^0.17.0

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

zkure5ic

zkure5ic3#

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

1rhkuytd

1rhkuytd4#

对我来说,解决办法是使用

flutter pub upgrade

然后一切又像预期的那样工作了。

8yparm6h

8yparm6h5#

现在我面临这个问题。

/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) {
                ^^^^^^^^

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.

相关问题