Flutter Bloc&肘
我在此处关注教程: 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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您提供的日志中
您忘了使用
WeatherCubit
定义导入文件。From the log you provided
You forgot to import file with
WeatherCubit
definition.