fca 0.0.11
fca: ^0.0.11 copied to clipboard
A Flutter template based on Clean Architecture, designed for scalable and maintainable apps with a structured layer system and pre-configured state management.
FCA Library #
The FCA library offers essential building blocks and utilities for the FCA project. It includes core components for state management, dependency injection, network operations, error handling, and UI helpers.
Features #
- BLoC Components: Base classes for BLoC and BLoC consumers.
- Entities: Common data entities used in the application.
- Dependency Injection: Utilities for managing dependencies.
- Error Handling: Classes for handling various error scenarios.
- Network Utilities: Components for managing network requests and connectivity.
- UI Helpers: Utility functions for displaying UI components.
Installation #
Add the following dependency to your pubspec.yaml
:
dependencies:
fca: ^0.0.7
Usage #
BLoC Components #
base_bloc.dart
: Contains the base implementation of BLoC.base_consumer.dart
: Provides a base consumer for BLoC.
Example
import 'package:fca/fca.dart';
class MyBloc extends BaseBloc<MyEvent, MyState> {}
Dependency Injection #
dependency.dart
: Contains dependency injection setup and utilities.
Example
import 'package:fca/fca.dart';
Dependency.addRepository(MyRepository());
UI Helpers #
show_loading.dart
: Provides a function to display a loading indicator.show_snackbar.dart
: Provides a function to show a custom snackbar.
Example
import 'package:fca/fca.dart';
void someFunction(BuildContext context) {
showLoading(context);
showSnackBar(context, 'Operation completed!');
}
Error Handling #
failure.dart
: Defines theFailure
class for error scenarios.response_exception.dart
: DefinesResponseException
for HTTP errors.server_exception.dart
: DefinesServerException
for server-related errors.
Network Utilities #
connection_checker.dart
: Provides network connectivity checking withConnectionChecker
and its implementation.intercepted_client.dart
: ImplementsInterceptedClient
for managing HTTP requests with token handling.
Example
import 'package:fca/fca.dart';
import 'package:http/http.dart' as http;
class MyClient extends InterceptedClient {
MyClient(http.Client client, String authorizationType)
: super(client: client, authorizationType: authorizationType);
@override
Future<String> getToken() async {
// Implement token retrieval logic here
return 'your-token';
}
@override
Future<void> refreshToken() async {
// Implement token refresh logic here
}
@override
String modifyJsonResponse(String responseBody) {
// Implement JSON response modification here
return responseBody;
}
}
Use Case #
usecase.dart
: Defines theUseCase
class andNoParams
class for managing business logic operations.
License #
This project is licensed under the MIT License - see the LICENSE file for details.