VS 代码正在导入重命名的包

分享于2022年07月17日 dart flutter visual-studio visual-studio-code 问答
【问题标题】:VS 代码正在导入重命名的包(VS code is importing renamed packages)
【发布时间】:2022-07-13 01:48:43
【问题描述】:

我将 Warehouse_edit_repository.dart 重命名为 warehouse_edit_repository.dart

但是当我导入文件并尝试运行程序时,我得到了这个错误

 - 'WarehouseEditRepository/*1*/' is from 'package:bhoomi/data/repository/warehouse_edit_repository.dart' ('lib/data/repository/warehouse_edit_repository.dart').
 - 'WarehouseEditRepository/*2*/' is from 'package:bhoomi/data/repository/Warehouse_edit_repository.dart' ('lib/data/repository/Warehouse_edit_repository.dart').
          EditWarehouseBloc(editWarehouseRepository: WarehouseEditRepository())
                                                     ^
lib/screens/project_screens/purch_mgmt_screens/masters/warehouse_screen/warehouse_edit_screen.dart:178:14: Error: Type argument 'EditWarehouseBloc' doesn't conform to the bound 'BlocBase' of the type variable 'B' on 'BlocConsumer'.
 - 'EditWarehouseBloc' is from 'package:bhoomi/bloc/warehouse_view_bloc/warehouse_view_bloc.dart' ('lib/bloc/warehouse_view_bloc/warehouse_view_bloc.dart').
 - 'BlocBase' is from 'package:bloc/src/bloc.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/bloc-7.2.1/lib/src/bloc.dart').
Try changing type arguments so that they conform to the bounds.
      child: BlocConsumer(
             ^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bloc-7.3.3/lib/src/bloc_consumer.dart:61:20: Context: This is the type variable whose bound isn't conformed to.
class BlocConsumer, S> extends StatefulWidget {
                   ^
lib/screens/project_screens/purch_mgmt_screens/masters/warehouse_screen/warehouse_edit_screen.dart:702:58: Error: The argument type 'AddWarehouseModel/*1*/' can't be assigned to the parameter type 'AddWarehouseModel/*2*/'.
 - 'AddWarehouseModel/*1*/' is from 'package:bhoomi/data/model/add_warehouse_repository.dart' ('lib/data/model/add_warehouse_repository.dart').
 - 'AddWarehouseModel/*2*/' is from 'package:bhoomi/data/model/add_Warehouse_repository.dart' ('lib/data/model/add_Warehouse_repository.dart').
                                                  model: model));
                                                         ^


FAILURE: Build failed with an exception.

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

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\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.

我删除了 vs 代码,尝试再次编写代码删除导入并再次导入在导入中使用 as 但不起作用。有什么解决办法吗?


【解决方案1】:

您的 import 语句可能仍在使用旧的大小写。尝试在 VS Code 中启用大小写敏感设置的情况下在工作区中搜索 Warehouse_edit_repository add_Warehouse_repository ,并更正任何使用错误大小写的内容。