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 the Failure class for error scenarios.
  • response_exception.dart: Defines ResponseException for HTTP errors.
  • server_exception.dart: Defines ServerException for server-related errors.

Network Utilities

  • connection_checker.dart: Provides network connectivity checking with ConnectionChecker and its implementation.
  • intercepted_client.dart: Implements InterceptedClient 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 the UseCase class and NoParams class for managing business logic operations.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Libraries

fca
A library for common components and utilities used in the FCA project.