Flutter Bloc&肘

发布于 2025-01-24 03:19:54 字数 3316 浏览 3 评论 0原文

我在此处关注教程: https://resocoder.com/ 2020/08/04/Flutter-Bloc-Cubit-Tutearial/

当我到达“使用Cubit”部分和main.dart的“建筑物”时,我有以下问题:

“在此处输入映像说明”

我遇到的错误:

[{
    "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": {
        "value": "type_argument_not_matching_bounds",
        "target": {
            "$mid": 1,
            "external": "https://dart.dev/diagnostics/type_argument_not_matching_bounds",
            "path": "/diagnostics/type_argument_not_matching_bounds",
            "scheme": "https",
            "authority": "dart.dev"
        }
    },
    "severity": 8,
    "message": "'dynamic' doesn't conform to the bound 'StateStreamableSource<Object?>' of the type parameter 'T'.\nTry using a type that is or is a subclass of 'StateStreamableSource<Object?>'.",
    "source": "dart",
    "startLineNumber": 13,
    "startColumn": 13,
    "endLineNumber": 13,
    "endColumn": 25,
    "relatedInformation": [
        {
            "startLineNumber": 13,
            "startColumn": 13,
            "endLineNumber": 13,
            "endColumn": 25,
            "message": "The raw type was instantiated as 'BlocProvider<dynamic>', and is not regular-bounded.",
            "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart"
        }
    ]
}]
[{
    "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": "could_not_infer",
    "severity": 8,
    "message": "Couldn't infer type parameter 'T'.\n\nTried to infer 'dynamic' for 'T' which doesn't work:\n  Type parameter 'T' is declared to extend 'StateStreamableSource<Object?>' producing 'StateStreamableSource<Object?>'.\nThe type 'dynamic' was inferred from:\n  Parameter 'create' declared as     'T Function(BuildContext)'\n                     but argument is 'dynamic Function(BuildContext)'.\n\nConsider passing explicit type argument(s) to the generic.\n\n",
    "source": "dart",
    "startLineNumber": 13,
    "startColumn": 13,
    "endLineNumber": 13,
    "endColumn": 25
}]
[{
    "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": {
        "value": "undefined_method",
        "target": {
            "$mid": 1,
            "external": "https://dart.dev/diagnostics/undefined_method",
            "path": "/diagnostics/undefined_method",
            "scheme": "https",
            "authority": "dart.dev"
        }
    },
    "severity": 8,
    "message": "The method 'WeatherCubit' isn't defined for the type 'MyApp'.\nTry correcting the name to the name of an existing method, or defining a method named 'WeatherCubit'.",
    "source": "dart",
    "startLineNumber": 14,
    "startColumn": 30,
    "endLineNumber": 14,
    "endColumn": 42
}]

可以给我一些提示?

I am following the tutorial here: https://resocoder.com/2020/08/04/flutter-bloc-cubit-tutorial/.

When I reached the "Building with Cubit" part and in the main.dart, I have the following issue:

enter image description here

The errors I have:

[{
    "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": {
        "value": "type_argument_not_matching_bounds",
        "target": {
            "$mid": 1,
            "external": "https://dart.dev/diagnostics/type_argument_not_matching_bounds",
            "path": "/diagnostics/type_argument_not_matching_bounds",
            "scheme": "https",
            "authority": "dart.dev"
        }
    },
    "severity": 8,
    "message": "'dynamic' doesn't conform to the bound 'StateStreamableSource<Object?>' of the type parameter 'T'.\nTry using a type that is or is a subclass of 'StateStreamableSource<Object?>'.",
    "source": "dart",
    "startLineNumber": 13,
    "startColumn": 13,
    "endLineNumber": 13,
    "endColumn": 25,
    "relatedInformation": [
        {
            "startLineNumber": 13,
            "startColumn": 13,
            "endLineNumber": 13,
            "endColumn": 25,
            "message": "The raw type was instantiated as 'BlocProvider<dynamic>', and is not regular-bounded.",
            "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart"
        }
    ]
}]
[{
    "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": "could_not_infer",
    "severity": 8,
    "message": "Couldn't infer type parameter 'T'.\n\nTried to infer 'dynamic' for 'T' which doesn't work:\n  Type parameter 'T' is declared to extend 'StateStreamableSource<Object?>' producing 'StateStreamableSource<Object?>'.\nThe type 'dynamic' was inferred from:\n  Parameter 'create' declared as     'T Function(BuildContext)'\n                     but argument is 'dynamic Function(BuildContext)'.\n\nConsider passing explicit type argument(s) to the generic.\n\n",
    "source": "dart",
    "startLineNumber": 13,
    "startColumn": 13,
    "endLineNumber": 13,
    "endColumn": 25
}]
[{
    "resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": {
        "value": "undefined_method",
        "target": {
            "$mid": 1,
            "external": "https://dart.dev/diagnostics/undefined_method",
            "path": "/diagnostics/undefined_method",
            "scheme": "https",
            "authority": "dart.dev"
        }
    },
    "severity": 8,
    "message": "The method 'WeatherCubit' isn't defined for the type 'MyApp'.\nTry correcting the name to the name of an existing method, or defining a method named 'WeatherCubit'.",
    "source": "dart",
    "startLineNumber": 14,
    "startColumn": 30,
    "endLineNumber": 14,
    "endColumn": 42
}]

Can give me some hints on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2025-01-31 03:19:54

从您提供的日志中

未针对“ myapp”类型定义方法“ weathercubit”。

您忘了使用WeatherCubit定义导入文件。

From the log you provided

The method 'WeatherCubit' isn't defined for the type 'MyApp'.\nTry correcting the name to the name of an existing method, or defining a method named 'WeatherCubit'.

You forgot to import file with WeatherCubit definition.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文