运行 滑动启动后导入不明确
Ambiguous import after run slidy start
我刚开始使用 Flutter,我一直在寻找这个问题,但我没有找到任何东西。
我 运行 命令 slidy start 以创建我的项目 structure.But 现在,我在应用程序模块中收到此错误导入路由器冲突:
The name 'Router' is defined in the libraries 'package:flutter/src/widgets/router.dart' and 'package:flutter_modular/src/routers/router.dart (via package:flutter_modular/flutter_modular.dart)'.\nTry using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports."
这是我现在的class:
import 'app_controller.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutter/material.dart';
import 'package:slidy_aula2_v1/app/app_widget.dart';
import 'package:slidy_aula2_v1/app/modules/home/home_module.dart';
class AppModule extends MainModule {
@override
List<Bind> get binds => [
Bind((i) => AppController()),
];
@override
List<Router> get routers => [
Router(Modular.initialRoute, module: HomeModule()),
];
@override
Widget get bootstrap => AppWidget();
static Inject get to => Inject<AppModule>.of();
}
大家都知道怎么解决吗?
您在
中有两个路由器class
包:flutter/src/widgets/router.dart
和
包:flutter_modular/src/routers/router.dart
定义 flutter_modular 包的前缀:
import 'package:flutter_modular/flutter_modular.dart' as ModularRouter;
如果您在 flutter_modular 中使用路由器 class,请将路由器更改为 ModularRouter.Router。
class AppModule extends MainModule {
@override
List<Bind> get binds => [
Bind((i) => AppController()),
];
@override
List<ModularRouter.Router> get routers => [
ModularRouter.Router(Modular.initialRoute, module: HomeModule()),
];
@override
Widget get bootstrap => AppWidget();
static Inject get to => Inject<AppModule>.of();
}
我刚开始使用 Flutter,我一直在寻找这个问题,但我没有找到任何东西。
我 运行 命令 slidy start 以创建我的项目 structure.But 现在,我在应用程序模块中收到此错误导入路由器冲突:
The name 'Router' is defined in the libraries 'package:flutter/src/widgets/router.dart' and 'package:flutter_modular/src/routers/router.dart (via package:flutter_modular/flutter_modular.dart)'.\nTry using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports."
这是我现在的class:
import 'app_controller.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutter/material.dart';
import 'package:slidy_aula2_v1/app/app_widget.dart';
import 'package:slidy_aula2_v1/app/modules/home/home_module.dart';
class AppModule extends MainModule {
@override
List<Bind> get binds => [
Bind((i) => AppController()),
];
@override
List<Router> get routers => [
Router(Modular.initialRoute, module: HomeModule()),
];
@override
Widget get bootstrap => AppWidget();
static Inject get to => Inject<AppModule>.of();
}
大家都知道怎么解决吗?
您在
中有两个路由器class包:flutter/src/widgets/router.dart
和
包:flutter_modular/src/routers/router.dart
定义 flutter_modular 包的前缀:
import 'package:flutter_modular/flutter_modular.dart' as ModularRouter;
如果您在 flutter_modular 中使用路由器 class,请将路由器更改为 ModularRouter.Router。
class AppModule extends MainModule {
@override
List<Bind> get binds => [
Bind((i) => AppController()),
];
@override
List<ModularRouter.Router> get routers => [
ModularRouter.Router(Modular.initialRoute, module: HomeModule()),
];
@override
Widget get bootstrap => AppWidget();
static Inject get to => Inject<AppModule>.of();
}