Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Nov 18, 2023
1 parent 1933654 commit bcfeb55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class _MusifyState extends State<Musify> {
child: Navigator(
key: _navigatorKey,
initialRoute: RoutePaths.home,
onGenerateRoute: RouterService.generateRoute,
onGenerateRoute: generateRoute,
),
),
bottomNavigationBar: Column(
Expand Down
27 changes: 12 additions & 15 deletions lib/services/router_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ final destinations = [
RoutePaths.more,
];

// ignore: avoid_classes_with_only_static_members
class RouterService {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case RoutePaths.home:
return MaterialPageRoute(builder: (_) => HomePage());
case RoutePaths.search:
return MaterialPageRoute(builder: (_) => SearchPage());
case RoutePaths.userPlaylists:
return MaterialPageRoute(builder: (_) => UserPlaylistsPage());
case RoutePaths.more:
return MaterialPageRoute(builder: (_) => MorePage());
default:
throw Exception('Invalid route: ${settings.name}');
}
Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case RoutePaths.home:
return MaterialPageRoute(builder: (_) => HomePage());
case RoutePaths.search:
return MaterialPageRoute(builder: (_) => SearchPage());
case RoutePaths.userPlaylists:
return MaterialPageRoute(builder: (_) => UserPlaylistsPage());
case RoutePaths.more:
return MaterialPageRoute(builder: (_) => MorePage());
default:
throw Exception('Invalid route: ${settings.name}');
}
}

0 comments on commit bcfeb55

Please sign in to comment.