Jisho-Study-Tool/lib/router.dart

32 lines
851 B
Dart

import 'package:flutter/material.dart';
import 'view/home.dart';
import 'view/screens/search/kanji_result_page.dart';
import 'view/screens/search/search_results_page.dart';
Route<Widget> generateRoute(RouteSettings settings) {
final args = settings.arguments;
switch (settings.name) {
case '/':
return MaterialPageRoute(builder: (_) => const Home());
case '/search':
final searchTerm = args! as String;
return MaterialPageRoute(
builder: (_) => SearchResultsPage(searchTerm: searchTerm),
);
case '/kanjiSearch':
final searchTerm = args! as String;
return MaterialPageRoute(
builder: (_) => KanjiResultPage(kanjiSearchTerm: searchTerm),
);
default:
return MaterialPageRoute(
builder: (_) => const Text('ERROR: this route does not exist'),
);
}
}