【发布时间】:2020-07-23 18:12:33
【问题描述】:
我已遵循此指南:https://medium.com/flutter-community/flutter-vi-navigation-drawer-flutter-1-0-3a05e09b0db9
特别想复制抽屉。但是,我的 Routes.dart 文件中的静态常量出现错误。
代码如下所示: 在我的 lib/routes/routes.dart 文件中:
import 'package:book_club/main.dart';
class Routes {
static const String Profile = ProfilePage.routeName;
static const String BookClub = BookClubPage.routeName;
static const String Library = LibraryPage.routeName;
static const String Search = SearchPage.routeName;
static const String Store = StorePage.routeName;
}
它给了我以下两个错误:
- 错误:必须用常量值初始化常量变量。 (const_initialized_with_non_constant_value at [book_club] lib/Routes/routes.dart:2)
- 错误:未定义名称“ProfilePage”。 (undefined_identifier at [book_club] lib/Routes/routes.dart:2)
谁能帮助我理解我做错了什么?尝试多次阅读这篇文章,但找不到我的错误。我是一个完全的编程初学者,所以希望有一种简单明了的方法来解决这个问题:)
如果有什么不同,请使用 android studio。
【问题讨论】:
-
请发minimal reproducible example,至少是您使用的所有标识符。