This project is a simple hotel booking app built using Flutter, designed as part of a coding assignment. The app features a bottom navigation bar with four tabs: Overview, Search, Favorites, and Account. Each tab implements the necessary functionality, with a focus on state management, error handling, and navigation.
- Four tabs: Overview, Search, Favorites, Account.
- Displays hotel cards fetched from an API.
- Shows a loading spinner while fetching hotel data.
- Displays an error screen if the API call fails.
- API used for hotel data.
- Allows users to favorite/unfavorite hotels by tapping the heart icon.
- Displays the list of favorite hotels.
- Favorites are stored locally (using Hive).
- A simple error state is displayed if fetching hotels fails.
- Follows the design provided via Figma.
- Simple placeholders are used for loading and error states.
The app is built following Clean Architecture, with clear separation of concerns into the following layers:
- Data Layer: Handles API calls, local data storage, and repositories.
- Domain Layer: Contains business logic and interacts with the data layer via use cases.
- Presentation Layer: Consists of UI components and state management using BLoC to handle different app states such as loading, success, and error.
The BLoC pattern is used to manage app states efficiently. It handles API calls, updates UI states (loading, error, success), and manages the state of favorited hotels locally.
Implemented using the Auto Route package to handle tab-based navigation as well as deep linking.
- Hive is used for local storage to store favorited hotels.
- Flutter SDK.
- A suitable editor like VS Code or Android Studio.
- Clone the repository:
git clone https://github.com/yourusername/flutter-hotel-booking.git
- Navigate to the project directory:
cd flutter-hotel-booking
- Install dependencies:
flutter pub get
- Run the app:
flutter run
To run the unit and widget tests, use the following command:
flutter test
The app includes:
- Unit tests for the business logic.
- Widget tests to verify UI behavior.
Note: I have written different types of tests to showcase my skills in testing Flutter applications. However, I acknowledge that this project would benefit from more comprehensive test coverage, especially in areas such as edge cases and error handling.
Hotels Tab | Favorites Tab | Error State |
---|---|---|
- BLoC for State Management: Chosen for its robustness and clear separation of UI and business logic.
- Hive for Local Storage: Hive offers a lightweight and easy-to-use database solution to store and retrieve favorited hotels.
- Auto Route for Navigation: Simplifies navigation, especially for managing deep links and tab-based routing.
- Clean Architecture: Ensures maintainability, testability, and scalability, following the separation of concerns principle.
- More Tests: While I have included various tests, the project could benefit from more comprehensive unit and widget tests.
- Performance Optimization: Adding caching for API responses would help optimize data loading performance.
- Localization: The app currently lacks multi-language support but can be extended to include localization in the future.