Dart 没有顶级的getter<;类名>;宣布

Dart 没有顶级的getter<;类名>;宣布,dart,atom-editor,flutter,Dart,Atom Editor,Flutter,我正在扩展Flitter_gallery示例 我尝试创建新的库项目 new GalleryItem( title: 'Journal', subtitle: 'Example app coding', category: 'Apps', routeName: JournalDemo.routeName, buildRoute: (BuildContext context) => new JournalDemo() ), 我导入了import'../journal/jo

我正在扩展Flitter_gallery示例

我尝试创建新的库项目

new GalleryItem(
  title: 'Journal',
  subtitle: 'Example app coding',
  category: 'Apps',
  routeName: JournalDemo.routeName,
  buildRoute: (BuildContext context) => new JournalDemo()
),
我导入了
import'../journal/journal_all.dart'

里面我有
导出'journal_demo.dart';

JournalDemo
类与
ListDemo
是同一类,我只更改了类名和状态名:

class JournalDemo extends StatefulWidget {
  JournalDemo({ Key key }) : super(key: key);

  static const String routeName = '/journal';

  @override
  JournalDemoState createState() => new JournalDemoState();
} 

class JournalDemoState extends State<JournalDemo> {
 .......
类JournalDemo扩展StatefulWidget{ JournalDemo({Key}):超级(Key:Key); 静态常量字符串routeName='/journal'; @凌驾 JournalDemoState createState()=>新的JournalDemoState(); } 类JournalDemoState扩展状态{ .......
这是我得到的例外

I/颤振:══╡ WIDGETS库捕获到异常╞═══════════════════════════════════════════════════════════
I/flatter:在building GalleryApp中抛出以下NoSuchMethodError(脏;状态:
I/颤振:GalleryAppState(48280642)):
I/flutter:没有顶级的getter'JournalDemo'声明。
I/flatter:NoSuchMethodError:未找到方法:“JournalDemo”
I/颤振:接收器:顶级
I/flatter:参数:[……]
I/flatter:抛出异常时,这是堆栈:
I/flatter:#0无此方法错误。_throwNew(省道:核心补丁/错误补丁。省道:184)
I/flatter:#1个kAllGalleryItems(/Users/matej/IdeaProjects/flatter/journal/lib/gallery/item.dart:51)
I/flatter:#2个kAllGalleryItems(/Users/matej/IdeaProjects/flatter/journal/lib/gallery/item.dart:45)

我应该换什么


谢谢

这看起来您的代码中缺少导入或存在解析错误。我建议按照上面的海报之一的建议,使用
flatter analyze
进行检查


没有声明顶级getter'JournalDemo'
意味着它无法在全局范围内找到值
JournalDemo
。这可能是因为它没有导入,或者是因为在此错误之前存在解析错误。

您好,请随时联系我们(Flatter开发人员)通过电子邮件颤振-dev@googlegroups.com或者加入我们的Gitter:这可能是获得帮助的一种更快的方式。分析器会说什么?(
flatteranalyze
在应用程序目录中)我无法在本地复制此内容,正在进行您描述的更改?很高兴与您一起进行进一步调试。