import 'dart:io'; import 'package:tangocard_reader/models/data_entry.dart'; import 'package:tangocard_reader/models/router_args.dart'; import 'package:tangocard_reader/screens/practise/flashcard.dart'; import 'package:tangocard_reader/screens/home.dart'; import 'package:tangocard_reader/screens/pages/tango_list.dart'; import 'package:flutter/material.dart'; import 'screens/pages/kanji_list.dart'; class PageRouter { static Route generateRoute(RouteSettings settings) { final args = settings.arguments; switch (settings.name) { case '/': return MaterialPageRoute(builder: (_) => const Home()); case '/list/tango': final file = args as File; return MaterialPageRoute(builder: (_) => TangoList(file: file)); case '/list/kanji': final file = args as File; return MaterialPageRoute(builder: (_) => KanjiList(file: file)); case '/benkyou/tango': final benkyouArgs = args as BenkyouArgs; return MaterialPageRoute( builder: (_) => FlashcardView( cards: benkyouArgs.cards as List, index: benkyouArgs.index, ), ); case '/benkyou/kanji': // final benkyouArgs = args as BenkyouArgs; // return MaterialPageRoute( // builder: (_) => FlashcardView( // cards: benkyouArgs.cards as List, // index: benkyouArgs.index, // ), // ); default: return MaterialPageRoute( builder: (_) => Scaffold( appBar: AppBar(title: const Text('Error')), body: Center( child: ErrorWidget('No such route...') ), ), ); } } }