Overview
TheHome screen is the main landing page of the Aradia Audiobooks app. It displays various audiobook collections including recently played, local imports, YouTube imports, favorites, personalized recommendations, popular audiobooks, trending titles, and browsable genres.
File Location: lib/screens/home/home.dart
Purpose and Functionality
The Home screen serves as the central hub for audiobook discovery and access:- Displays personalized recommendations based on listening history
- Shows recently played audiobooks for quick resume
- Provides access to local and YouTube imported content
- Lists popular and trending audiobooks from LibriVox
- Offers genre-based browsing
- Checks for app updates on initialization
- Manages theme settings via app bar actions
Key Components
State Management
The screen uses multiple HomeBloc instances to manage different audiobook collections:Services
- RecommendationService: Generates personalized genre recommendations
- LatestVersionFetch: Checks for and downloads app updates
- PermissionHelper: Handles update installation permissions
Scroll Controllers
Separate scroll controllers for each horizontal audiobook section:Widget Structure
The screen uses aCustomScrollView with SliverToBoxAdapter sections:
- WelcomeSection - Greeting and user information
- HistorySection - Recently played audiobooks (max height: 290)
- LocalImportsSection - Locally imported audiobooks
- YoutubeImportsSection - YouTube imported content
- FavouriteSection - User’s favorite audiobooks
- Recommended Section - Personalized recommendations (FutureBuilder)
- MyAudiobooks (Popular) - Popular all-time audiobooks
- MyAudiobooks (Trending) - Trending this week
- GenreGrid - Browse genres section
- Footer - Search guidance text
BLoC Events
The Home screen works withHomeBloc which handles these events:
FetchLatestAudiobooks
FetchPopularAudiobooks
FetchPopularThisWeekAudiobooks
FetchAudiobooksByGenre
ResetHomeLists
BLoC States
TheHomeBloc emits these states:
Loading States
HomeInitial- Initial stateLatestAudiobooksFetchingLoadingStatePopularAudiobooksFetchingLoadingStatePopularAudiobooksOfWeekFetchingLoadingStateGenreAudiobooksFetchingLoadingState
Success States
LatestAudiobooksFetchingSuccessState(audiobooks)- Contains fetched latest audiobooksPopularAudiobooksFetchingSuccessState(audiobooks)- Contains popular audiobooksPopularAudiobooksOfWeekFetchingSuccessState(audiobooks)- Contains trending audiobooksGenreAudiobooksFetchingSuccessState(audiobooks)- Contains genre-filtered audiobooks
Failure States
LatestAudiobooksFetchingFailedStatePopularAudiobooksFetchingFailedStatePopularAudiobooksOfWeekFetchingFailedStateGenreAudiobooksFetchingFailedState
Navigation
The Home screen supports navigation to:Settings Screen
Genre Audiobooks Screen
Code Examples
Building Featured Sections
Lazy Load Recommended Section
Update Check Flow
Displaying Recommended Genres
Lifecycle Management
Initialization
Disposal
Dependencies
flutter_bloc- State managementprovider- Dependency injection and theme managementgo_router- Navigationgoogle_fonts- Typography (Ubuntu font family)hive- Local storage for recommendations and favorites
Constants
The screen referencesHomeConstants.genres for the genre grid, which contains predefined audiobook genres available for browsing.