Skip to content

Commit 89cc2db

Browse files
committed
Created Primary Documentation
1 parent 7d6fde1 commit 89cc2db

19 files changed

+1250
-0
lines changed

lib/injection.dart.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Internal Code Documentation - Dependency Injection Setup
2+
3+
**Table of Contents**
4+
5+
* [Introduction](#introduction)
6+
* [Dependency Injection Setup](#dependency-injection-setup)
7+
* [Data Sources](#data-sources)
8+
* [Repositories](#repositories)
9+
* [Use Cases](#use-cases)
10+
* [BLoCs & Cubits](#blocs-cubits)
11+
12+
### Introduction
13+
14+
This code snippet demonstrates how to set up dependency injection using the `GetIt` package in a Flutter application. Dependency injection is a powerful technique that helps decouple different parts of your application, making it easier to test, maintain, and scale.
15+
16+
### Dependency Injection Setup
17+
18+
The code uses the `GetIt` package to implement dependency injection. `GetIt` is a simple and widely used dependency injection framework for Flutter.
19+
20+
**The `init()` function is responsible for registering all the dependencies:**
21+
22+
```dart
23+
final locator = GetIt.instance;
24+
25+
void init() {
26+
// ... register dependencies ...
27+
}
28+
```
29+
30+
**`locator` is a global instance of `GetIt` that provides access to registered dependencies.**
31+
32+
#### Data Sources
33+
34+
* **`AuthenticationRemoteDataSourceImpl`:** This class is responsible for fetching data from a remote source (e.g., an API) related to authentication. It's registered as a lazy singleton, meaning that it will only be created when it's first requested.
35+
```dart
36+
final authRemoteDataSource = AuthenticationRemoteDataSourceImpl();
37+
locator.registerLazySingleton<AuthenticationRemoteDataSource>(
38+
() => authRemoteDataSource,
39+
);
40+
```
41+
42+
#### Repositories
43+
44+
* **`AuthenticationRepositoryImpl`:** This class acts as an intermediary between the UI and the data source. It fetches data from the `AuthenticationRemoteDataSource` and provides a clean interface for the UI to interact with. It's also registered as a lazy singleton.
45+
```dart
46+
final authRepository = AuthenticationRepositoryImpl(locator());
47+
locator.registerLazySingleton<AuthenticationRepository>(
48+
() => authRepository,
49+
);
50+
```
51+
52+
#### Use Cases
53+
54+
* **`SignIn`:** This class encapsulates the logic for signing in a user. It takes the `AuthenticationRepository` as a dependency to interact with authentication data. It's also registered as a lazy singleton.
55+
```dart
56+
final signIn = SignIn(locator());
57+
locator.registerLazySingleton(
58+
() => signIn,
59+
);
60+
```
61+
62+
#### BLoCs & Cubits
63+
64+
* **`AuthenticatorWatcherBloc`:** This BLoC (Business Logic Component) is responsible for monitoring the authentication state of the user. It is also registered as a lazy singleton.
65+
```dart
66+
final authenticatorWatcherBloc = AuthenticatorWatcherBloc();
67+
locator.registerLazySingleton(
68+
() => authenticatorWatcherBloc,
69+
);
70+
```
71+
72+
* **`SignInFormBloc`:** This BLoC manages the state of the sign-in form, handling user input and validation. It takes the `SignIn` use case as a dependency to handle the actual sign-in process. It's also registered as a lazy singleton.
73+
```dart
74+
final signInFormBloc = SignInFormBloc(locator());
75+
locator.registerLazySingleton(
76+
() => signInFormBloc,
77+
);
78+
```
79+
80+
* **`ThemeCubit`:** This Cubit manages the current theme of the application. It's also registered as a lazy singleton.
81+
```dart
82+
final themeCubit = ThemeCubit();
83+
locator.registerLazySingleton(
84+
() => themeCubit,
85+
);
86+
```
87+
88+
89+
**Benefits of Dependency Injection:**
90+
91+
* **Testability:** Easy to mock dependencies for unit testing.
92+
* **Maintainability:** Changes in one part of the application have less impact on other parts.
93+
* **Reusability:** Dependencies can be reused in different parts of the application.
94+
* **Scalability:** Helps manage large and complex applications.

lib/main.dart.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## 📑 Internal Code Documentation
2+
3+
### 📚 Table of Contents
4+
5+
1. **Introduction**
6+
2. **Core Functionality**
7+
3. **Dependency Injection**
8+
4. **App Initialization**
9+
5. **Main Application Widget (MyApp)**
10+
6. **Theme Management**
11+
7. **Routing**
12+
13+
### 1. Introduction
14+
15+
This code implements a Flutter application built with a clean architecture approach leveraging Bloc and Cubit libraries for state management. It demonstrates a well-structured project setup with dependency injection, theme management, and a router for navigation.
16+
17+
### 2. Core Functionality
18+
19+
The application features the following core functionalities:
20+
21+
| Feature | Description |
22+
|---|---|
23+
| **Authentication** | Manages user authentication through `AuthenticatorWatcherBloc`. |
24+
| **Sign In** | Allows users to sign in with `SignInFormBloc`. |
25+
| **Theme Switching** | Enables users to toggle between light and dark themes using `ThemeCubit`. |
26+
| **Routing** | Provides navigation between different application screens using `GoRouter`. |
27+
28+
### 3. Dependency Injection
29+
30+
The application utilizes dependency injection to manage dependencies and promote modularity.
31+
32+
* **Dependency Injection Container:** The `injection.dart` file contains the dependency injection container (`di.locator`) using a library like `get_it`.
33+
* **Dependency Registration:** All necessary dependencies are registered in the `injection.dart` file, ensuring proper initialization and access throughout the application.
34+
* **Injection Usage:** The `di.locator` is used to fetch dependencies within the application, such as in `MultiBlocProvider` and other components.
35+
36+
### 4. App Initialization
37+
38+
The `main()` function initializes the application by:
39+
40+
* Ensuring Flutter widgets are initialized: `WidgetsFlutterBinding.ensureInitialized()`.
41+
* Setting a sequential bloc concurrency strategy: `Bloc.transformer = bloc_concurrency.sequential()`.
42+
* Registering the `AppBlocObserver` for observing bloc events: `Bloc.observer = const AppBlocObserver()`.
43+
* Initializing the dependency injection container: `di.init()`.
44+
* Running the application: `runApp(const MyApp())`.
45+
46+
### 5. Main Application Widget (MyApp)
47+
48+
The `MyApp` widget is the root widget of the application. It:
49+
50+
* Provides a `MultiBlocProvider` for managing multiple blocs:
51+
* `AuthenticatorWatcherBloc`: Watches for authentication state changes.
52+
* `SignInFormBloc`: Manages the sign-in form.
53+
* `ThemeCubit`: Manages theme switching.
54+
* Uses `MaterialApp.router` for routing:
55+
* Disables the debug banner: `debugShowCheckedModeBanner: false`.
56+
* Sets the application title: `title: 'flutter bloc clean architecture'`.
57+
* Configures light and dark themes: `theme` and `darkTheme`.
58+
* Uses system theme mode: `themeMode: ThemeMode.system`.
59+
* Initializes the router: `routerConfig: routerinit`.
60+
61+
### 6. Theme Management
62+
63+
The application uses a `ThemeCubit` to manage theme switching between light and dark modes:
64+
65+
* **ThemeCubit:** The `ThemeCubit` handles the current theme state and provides methods for changing the theme.
66+
* **ThemeData:** The `themeLight(context)` and `themeDark(context)` functions define the light and dark theme styles, respectively.
67+
* **Theme Mode:** `ThemeMode.system` ensures the theme follows the system settings.
68+
69+
### 7. Routing
70+
71+
The application uses `GoRouter` to manage navigation between different screens:
72+
73+
* **Router Initialization:** The `routerinit` variable, initialized in `go_router_init.dart`, defines the application's routes and associated screens.
74+
* **Routing Configuration:** The `routerConfig` property within `MaterialApp.router` is used to configure the router.
75+
76+
**Note:** The specific implementation details of the routes and screens are not included in this documentation. However, the basic structure and purpose are outlined.

lib/src/comman/api.dart.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## API Class Documentation
2+
3+
### Table of Contents
4+
5+
- [Overview](#overview)
6+
- [Authentication Endpoints](#authentication-endpoints)
7+
8+
### Overview
9+
10+
The `API` class defines the base URL and endpoints for interacting with the backend API.
11+
12+
**Base URL:**
13+
14+
The `BASE_URL` constant holds the base URL for all API requests. This should be replaced with the actual API base URL.
15+
16+
### Authentication Endpoints
17+
18+
The `API` class defines two endpoints for authentication:
19+
20+
| Endpoint | Description |
21+
|---|---|
22+
| `LOGIN` | Logs in a user. |
23+
| `REGISTER` | Registers a new user. |
24+
25+
**Example:**
26+
27+
```dart
28+
// Example usage of API endpoints
29+
final loginUrl = API.LOGIN; // "$BASE_URL/users/login"
30+
final registerUrl = API.REGISTER; // "$BASE_URL/users/register"
31+
```

lib/src/comman/colors.dart.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Color Palette Documentation
2+
3+
This document outlines the color palette used in the application.
4+
5+
### Table of Contents
6+
7+
* [Light Theme](#light-theme)
8+
* [Dark Theme](#dark-theme)
9+
10+
### <a name="light-theme"></a> Light Theme
11+
12+
| Color Name | Hex Code | Description |
13+
|---|---|---|
14+
| Primary | `#102c57` | The primary color used throughout the application. |
15+
| Background | `#FAFAFA` | The background color for most screens. |
16+
| Card | `#FFFFFF` | The background color for cards and other content containers. |
17+
| Font Title | `#202020` | The color used for primary text titles. |
18+
| Font Subtitle | `#737373` | The color used for secondary text titles. |
19+
| Font Disable | `#9B9B9B` | The color used for disabled text. |
20+
| Disabled Button | `#B9B9B9` | The color used for disabled buttons. |
21+
| Divider | `#DCDCDC` | The color used for dividers. |
22+
| Success | `#81C784` | The color used to indicate success. 💚 |
23+
| Warning | `#FFFFB74D` | The color used to indicate warnings. ⚠️ |
24+
| Error | `#E57373` | The color used to indicate errors. 🚨 |
25+
| Info | `#64B5F6` | The color used to indicate informational messages. ℹ️ |
26+
| Silver Tree | `#5FB4A5` | A specific color used in the application. |
27+
| Cat Skill White | `#F0F5F9` | A specific color used in the application. |
28+
| Half Dutch White | `#FFFFF6E1` | A specific color used in the application. |
29+
| White Smoke | `#F3F4F8` | A specific color used in the application. |
30+
| Link Water | `#DAE7F1` | A specific color used in the application. |
31+
32+
### <a name="dark-theme"></a> Dark Theme
33+
34+
| Color Name | Hex Code | Description |
35+
|---|---|---|
36+
| Primary | `#149CFC` | The primary color used throughout the application. |
37+
| Background | `#303030` | The background color for most screens. |
38+
| Card | `#424242` | The background color for cards and other content containers. |
39+
| Font Title | `#FFFFFF` | The color used for primary text titles. |
40+
| Font Subtitle | `#C1C1C1` | The color used for secondary text titles. |
41+
| Font Disable | `#989898` | The color used for disabled text. |
42+
| Disabled Button | `#6E6E6E` | The color used for disabled buttons. |
43+
| Divider | `#494949` | The color used for dividers. |
44+
| Success | `#62F96A` | The color used to indicate success. 💚 |
45+
| Warning | `#F57C00` | The color used to indicate warnings. ⚠️ |
46+
| Error | `#D32F2F` | The color used to indicate errors. 🚨 |
47+
| Info | `#1976D2` | The color used to indicate informational messages. ℹ️ |

lib/src/comman/constant.dart.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Internal Code Documentation - Constants
2+
3+
### Table of Contents
4+
- [String Constants](#string-constants)
5+
- [Double Constants](#double-constants)
6+
7+
### String Constants
8+
9+
| Constant | Value | Description |
10+
|---|---|---|
11+
| `ACCESS_TOKEN` | `'access_token'` | Represents the key for storing the access token. |
12+
| `ONBOARDING` | `'onboarding'` | Represents the key for storing onboarding data. |
13+
14+
### Double Constants
15+
16+
| Constant | Value | Description |
17+
|---|---|---|
18+
| `MARGIN` | `18` | Represents the default margin value. |
19+
| `RADIUS` | `8` | Represents the default radius value. |
20+
| `SPACE8` | `8` | Represents a spacing value of 8. |
21+
| `SPACE4` | `4` | Represents a spacing value of 4. |
22+
| `SPACE12` | `12` | Represents a spacing value of 12. |
23+
| `SPACE15` | `15` | Represents a spacing value of 15. |
24+
| `SPACE25` | `25` | Represents a spacing value of 25. |

lib/src/comman/enum.dart.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Request State Enum Documentation
2+
3+
### Table of Contents
4+
5+
| Section | Description |
6+
|---|---|
7+
| [Overview](#overview) | General description of the code snippet |
8+
| [Enum Members](#enum-members) | Detailed information about each enum member |
9+
10+
### Overview
11+
12+
This code snippet defines an enumeration (enum) called `RequestState`, which represents the various states of a network request.
13+
14+
```python
15+
b'enum RequestState { empty, loading, error, loaded }'
16+
```
17+
18+
### Enum Members
19+
20+
| Member | Description |
21+
|---|---|
22+
| `empty` | The request hasn't been initiated yet. ⏳ |
23+
| `loading` | The request is currently in progress. 🔄 |
24+
| `error` | An error occurred during the request. ⚠️ |
25+
| `loaded` | The request has successfully completed. ✅ |
26+
27+
This enum is useful for managing the UI state of an application based on the status of a network request. For example, you might use the following logic:
28+
29+
* When the request state is `empty`, display a placeholder or loading indicator.
30+
* When the request state is `loading`, display a loading indicator.
31+
* When the request state is `error`, display an error message.
32+
* When the request state is `loaded`, display the data from the successful request.
33+
34+
This ensures that the user interface accurately reflects the current state of the request, providing a better user experience.

lib/src/comman/exception.dart.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Exception Types
2+
3+
This document outlines the exception types used in the application.
4+
5+
### Table of Contents
6+
7+
| Section | Description |
8+
|---|---|
9+
| [ServerException](#serverexception) | Exception related to server-side errors. |
10+
| [DatabaseException](#databaseexception) | Exception related to database operations. |
11+
| [CacheException](#cacheexception) | Exception related to cache operations. |
12+
13+
### <a name="serverexception"></a> ServerException
14+
15+
The `ServerException` class represents an exception related to server-side errors.
16+
17+
```dart
18+
class ServerException implements Exception {
19+
20+
ServerException(this.message);
21+
final String message;
22+
}
23+
```
24+
25+
**Properties:**
26+
27+
| Name | Type | Description |
28+
|---|---|---|
29+
| `message` | `String` | The error message associated with the exception. |
30+
31+
### <a name="databaseexception"></a> DatabaseException
32+
33+
The `DatabaseException` class represents an exception related to database operations.
34+
35+
```dart
36+
class DatabaseException implements Exception {
37+
38+
DatabaseException(this.message);
39+
final String message;
40+
}
41+
```
42+
43+
**Properties:**
44+
45+
| Name | Type | Description |
46+
|---|---|---|
47+
| `message` | `String` | The error message associated with the exception. |
48+
49+
### <a name="cacheexception"></a> CacheException
50+
51+
The `CacheException` class represents an exception related to cache operations.
52+
53+
```dart
54+
class CacheException implements Exception {
55+
56+
CacheException(this.message);
57+
final String message;
58+
}
59+
```
60+
61+
**Properties:**
62+
63+
| Name | Type | Description |
64+
|---|---|---|
65+
| `message` | `String` | The error message associated with the exception. |

0 commit comments

Comments
 (0)