Jisho-Study-Tool/lib/router.dart

32 lines
851 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2021-12-06 20:26:52 +01:00
import 'view/home.dart';
2021-12-01 23:09:53 +01:00
import 'view/screens/search/kanji_result_page.dart';
import 'view/screens/search/search_results_page.dart';
2021-12-06 20:26:52 +01:00
Route<Widget> generateRoute(RouteSettings settings) {
2021-12-01 23:09:53 +01:00
final args = settings.arguments;
2021-12-01 23:09:53 +01:00
switch (settings.name) {
case '/':
return MaterialPageRoute(builder: (_) => const Home());
2021-12-01 23:09:53 +01:00
case '/search':
2021-12-04 05:22:58 +01:00
final searchTerm = args! as String;
2021-12-01 23:09:53 +01:00
return MaterialPageRoute(
builder: (_) => SearchResultsPage(searchTerm: searchTerm),
);
2021-12-01 23:09:53 +01:00
case '/kanjiSearch':
2021-12-04 05:22:58 +01:00
final searchTerm = args! as String;
2021-12-01 23:09:53 +01:00
return MaterialPageRoute(
builder: (_) => KanjiResultPage(kanjiSearchTerm: searchTerm),
);
2021-12-01 23:09:53 +01:00
default:
return MaterialPageRoute(
builder: (_) => const Text('ERROR: this route does not exist'),
);
}
}