Welcome to the Unsplash Sample Flutter Project! This repository showcases the implementation of Flutter concepts such as Bloc pattern, Dependency Injection (DI), Code Coverage, Testing, Clean Architecture, Analytics using Mixpanel, Feature flagging & A/B testing using Unleash. Whether you're a Flutter enthusiast or a developer aiming to learn these practices, this project offers valuable insights.
- Features
- Getting Started
- Project Structure
- Dependency Injection
- Testing
- CodeCoverage
- License
- Analytics
- A/B Testing
- Implementation of the Bloc pattern for efficient state management.
- Utilization of GetIt for managing and injecting dependencies.
- Codecov setup to ensure thorough testing and quality assurance.
- Well-organized project structure following Clean Architecture principles.
- Utilization of Unleash to demonstrate feature flagging.
- Utilization of Unleash and Mixpanel to demonstrate A/B testing.
- Integration of MixPanel to track user behavior and analyze app usage patterns for better insights.
Follow these steps to set up and run the project on your local machine.
- Ensure that you have Flutter installed on your machine.
- Git
- Docker
- Ensure that you have Unplash API key
- Ensure that you have Mixpanel API key
-
Clone the repository:
git clone https://github.com/AyushBherwani1998/unsplash_sample.git
-
Navigate to the project directory:
cd unsplash_sample
-
Install dependencies:
flutter pub get
- Clone the Unleash repo:
git clone git@github.com:Unleash/unleash.git cd unleash
- Create and attach container:
docker compose up -d
The Unleash instance will be up and running on localhost:4242. The default username and password will be admin
& unleash4all
respectively.
You need to setup envoirment while working on this sample. Create a .env
file under lib/core/
with the following content:
UNSPLASH_API_KEY = hgs9ZVWrHQncX8d9tLmy-zq21412
UNLEASH_API_KEY = *:development.xxxxyyyyzzz
MIXPANEL_API_KEY = f9cbf11xxxxxxxxxxxxc695db39a
The project adheres to Clean Architecture principles, promoting separation of concerns and maintainability. Notable directories include:
lib/features/**
: Contains the primary application code.lib/features/**/data/
: Manages data handling, repositories, and data sources.lib/features/**/domain/
: Encompasses business logic, use cases, and entities.lib/features/**/presentation/
: Handles UI components, Blocs, and Widgets.
Dependency Injection (DI) is facilitated using the get_it package. This fosters organized code and enhanced testability by efficiently managing dependencies.
Unit and widget tests are included to ensure code reliability. Execute tests with the following command:
flutter test
Code coverage is enforced using test coverage tools like codecov. This helps track tested code areas and identifies segments needing more thorough testing. You can checkout the Grid graph for the repo below:
For app analytics we are using Mixpanel. It's used to track the user behavoiour and usage pattern in the application. You can checkout a gist of app analytics in the screenshot given below:
For the app we are using Unleash to perform A/B testing and mixpanel to collect analytics and funnel.
- Create
likeOptionExperiment
flag in Unleash instance with toggle calledexperiment
- Create two varinats
gridTile
andimageDetails
for testing - Enable the flags 🎉
Below is a funnel screenshot for “like image” experimentation
MIT License
Copyright (c) 2023 Ayush Bherwani
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.