Code Organization
A good coding convention must be complemented by good code organization on the macro level. A self-explanatory directory structures make the project more extensible and maintainable. Debugging is a lot easier. Besides, it guides folks new to the code base to understand code better.
Directory Structure of lib/
β
ββββlib
β β config.dart -> contains API keys
β β generated_plugin_registrant.dart -> auto-generated by flutter
β β main.dart -> starting point of the app
β β
β ββββbloc -> [DIR] in BLoC pattern
β β β argument_models.dart -> classes/models for passing arguments b/w pages
β β β auth.dart -> functions related to user authentication
β β β string_helpers.dart -> misc. string manipulation function
β β β
β β ββββapi_callers -> [DIR] contains functions that make API calls
β β recommendation_helpers.dart -> helper functions to fetch song recommendations
β β user_data_helpers.dart -> helper functions to fetch user profile data
β β
β ββββpages -> [DIR] contains all the widgets that make up pages of the app
β β auth_intermediate.dart -> intermediate screen b/w auth redirect and user profile page
β β menu.dart -> Main Initial screen with sign in button
β β search_results.dart -> Page displaying results of searching songs
β β search_screen.dart -> Page prompting user to search for a song
β β song_view.dart -> Page displaying selected song and recommendations
β β undefined_view.dart -> Page to redirect to when URL is unknown, similar to 404 page.
β β user_profile.dart -> Page with User's stats
β β
β ββββrouting -> [DIR] contains everything related to routing with URLs
β β router.dart -> Contains functions to route user to pages appropriately
β β route_names.dart -> Contains constants to implement named routing done by router.dart
β β
β ββββthemes -> [DIR] to store various themes of the app
β β maintheme.dart -> applies the primary themes of the app
β β
β ββββwidgets -> [DIR] contains standalone widgets that will be embedded onto pages
β β custom_list_tiles.dart -> custom-made ListTile widget to create larger sized tiles
β β
β ββββprofile_widgets -> [DIR] contains all widgets related to UserProfile page
β β β headings.dart -> Widget creates headings in the UserProfile page
β β β profile_header.dart -> Displays user details in UserProfile page
β β β top_artists.dart -> Displays top artists the user listens to
β β β top_tracks.dart -> Displays top tracks the user listens to
β β β
β β ββββcards -> [DIR] contains all Card widgets
β β analysis_card.dart -> Displays User's Listening Analysis
β β by_duration_card.dart -> Displays Tracks by duration
β β by_popularity_card.dart -> Displays Tracks by popularity
β β by_release_date_card.dart -> Displays Tracks by release date
β β
β ββββsong_view_widgets -> [DIR] contains widgets of SongView
β recommendations_list.dart -> Displays list of recommendations
β song_header.dart -> Displays enlarged header containing song detailsLast updated