This is a Flutter authentication app showcasing Clean Architecture, BLoC pattern, and dependency injection. It uses Firebase for authentication and provides a solid foundation for building scalable, maintainable Flutter applications.
-
User Authentication: Allows users to sign up, log in, and log out securely using Firebase Authentication.
-
Clean Architecture: Follows a modular and structured approach for better code organization, testability, and maintainability.
-
BLoC Pattern: Utilizes the BLoC pattern for state management to keep UI and business logic separated.
-
Dependency Injection: Implements dependency injection for better code decoupling and testability using
get_it
.
- Clone the repository:
git clone https://github.com/Ibrahim-Rafei/flutter_clean_architecture_authentication.git
- Navigate to the project directory:
cd flutter_clean_architecture_authentication
- Install dependencies:
flutter pub get
- Run the app:
flutter run
Before running the app, follow these steps to set up Firebase and configure your Flutter app for authentication:
-
Configure Firebase for Flutter:
- Open a terminal and navigate to your Flutter project directory.
- Download npm
- Run the following command to configure Firebase for your project:
npm install -g firebase-tools dart pub global activate flutterfire_cli flutterfire configure
-
Configure Authentication:
- In your Firebase project, navigate to the Authentication section.
- Enable the Email/Password sign-in method.
- Follow the Firebase documentation to set up additional authentication methods, including Google Sign-In.
-
Add Firebase Configuration Files:
-
For Android:
- Download the
google-services.json
file. - Place the file in
android/app/google-services.json
. - Obtain the SHA-1 fingerprint for your Android app by running the following command in the terminal from your Android project directory:
./gradlew signingReport
- Add the obtained SHA-1 fingerprint to the Firebase Console in the "SHA certificate fingerprints" section.
- Download the
-
For iOS:
- Download the
GoogleService-Info.plist
file. - Place the file in
ios/Runner/GoogleService-Info.plist
.
- Download the
-
-
Run Your Flutter App:
- Your Flutter app is now connected to Firebase for authentication.
This project follows the Clean Architecture principles for better separation of concerns and scalability:
-
Presentation Layer: Contains the UI components, BLoCs, and Widgets.
-
Domain Layer: Contains the business logic and entities. It is independent of any external frameworks.
-
Data Layer: Manages data sources, repositories, and data models. It interacts with external services like Firebase.
To run the tests, use the following command:
flutter run
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is in the public domain. You are free to use, modify, and distribute it without any restrictions.
-
Reso Coder's Flutter Clean Architecture series for the excellent tutorials on Flutter architecture.
-
BloC Library for providing a solid foundation for BLoC pattern implementation.