3

flutter_gallery の例を拡張しています。

新しいギャラリー アイテムを作成しようとしています

new GalleryItem(
  title: 'Journal',
  subtitle: 'Example app coding',
  category: 'Apps',
  routeName: JournalDemo.routeName,
  buildRoute: (BuildContext context) => new JournalDemo()
),

そして輸入しましたimport '../journal/journal_all.dart';

私が持っている中にexport 'journal_demo.dart';

JournalDemoclass は と同じクラスです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> {
 .......

これは私が得る例外です

I/flutter : ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter : The following NoSuchMethodError was thrown building GalleryApp(dirty; state: I/flutter : GalleryAppState(48280642)): I/flutter : No top-level getter 'JournalDemo' declared. I/flutter : NoSuchMethodError: method not found: 'JournalDemo' I/flutter : Receiver: top-level I/flutter : Arguments: [...] I/flutter : When the exception was thrown, this was the stack: I/flutter : #0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:184) I/flutter : #1 kAllGalleryItems (/Users/matej/IdeaProjects/flutter/journal/lib/gallery/item.dart:51) I/flutter : #2 kAllGalleryItems (/Users/matej/IdeaProjects/flutter/journal/lib/gallery/item.dart:45)

何を変更すればよいですか?

ありがとうございました

4

1 に答える 1