Preparación del entorno iOS
Conceptos Fundamentales de Flutter
Configuración del Entorno iOS para Flutter
Personalización de Estilos y Temas en iOS
Ajustes Iniciales para iOS en Aplicaciones Flutter
Registro y Configuración de la Cuenta Apple Developer
Quiz: Preparación del entorno iOS
Fundamentos de BLoC y Firebase
Introducción a la Arquitectura BLoC en Flutter
Integración de BLoC en el Proyecto
Configuración del Proyecto en Firebase
Manejo Global de Estado con BLoC
Navegación y Autenticación
Navegación Avanzada con App Router y Pantalla Principal
Diseño de Interfaz para la Pantalla de Inicio de Sesión
Pantalla de Login: Inputs y Validaciones
Diseño del Flujo de la Aplicación con Router
Implementación de Rutas en iOS
Gestión de Usuarios y Cierre de Sesión
Diseño Avanzado en iOS
Diseño Avanzado con Widgets Cupertino
Gestos Nativos y Comportamientos Avanzados en iOS
Integración con Firestore usando BLoC
Integración de Firestore con BLoC
Arquitectura BLoC para Lectura de Datos en Firestore
Arquitectura BLoC para Creación de Datos en Firestore
Arquitectura BLoC para Eliminación de Datos en Firestore
Configuración de Múltiples Proveedores de Repositorio en BLoC
Funcionalidades con BLoC
BLoC Builder para el Dashboard
BLoC Builder para Gastos
BLoC Builder para Gastos Avanzados
BLoC Wallet
BLoC Transaction List
Agregar Transacciones con BLoC
Eliminar Transacciones con BLoC
Testing
Testing de Aplicaciones Flutter
You don't have access to this class
Keep learning! Join and start boosting your career
Vendor and repository architecture is critical to building scalable and maintainable applications. By implementing a system that allows us to manage multiple data sources and states, we can create more robust and flexible applications. In this article, we will explore how to configure multiple providers and repositories to handle both authentication and transactions in our application.
When developing complex applications, it is common to need to handle different states and data sources simultaneously. Instead of having a single provider handling all the information, we can implement a more modular and organized system.
To start, we need to modify our current configuration from a single provider to a system that can handle multiple providers:
// We change from BlockProvider to MultiBlockProviderMultiBlockProvider MultiBlockProvider( providers: [ // First provider for authentication BlocProvider( create: (context) => OutBloc( repository: RepositoryProvider.of<OutRepository>(context), ), ),), // Second provider for transactions BlocProvider( create: (context) => IncomeExpenseBloc( repository: RepositoryProvider.of<IncomeExpenseRepository>(context), ).add(TransactionsEvent()), ), ), ], child: // Here goes the main widget of the application)
With this structure, we are creating a MultiBlockProvider
that contains a list of providers. Each provider handles a specific functionality:
(OutBloc
).(IncomeExpenseBloc
).This separation of responsibilities allows each block to focus on its specific task, making the code more maintainable and easier to understand.
By separating providers by functionality, we achieve:
Similar to vendors, we also need to configure multiple repositories to handle different data sources. For this, we will use a MultiRepositoryProvider
:
MultiRepositoryProvider( providers: [ // Repository for authentication RepositoryProvider<OutRepository>( create: (context) => OutRepository(), ), // Repository for transactions RepositoryProvider<IncomeExpenseRepository>( create: (context) => IncomeExpenseRepository(), ), ), ], child: // Here goes the MultiBlockProvider)
In this configuration, we are creating two different repositories:
OutRepository
to handle authentication.IncomeExpenseRepository
to handle transactions.Each repository is responsible for interacting with its own data source, which allows a clear separation of responsibilities and makes the code more organized.
Using multiple repositories provides us with several advantages:
Once we have configured both providers and repositories, we need to integrate them into a coherent architecture. The general structure would be:
MultiRepositoryProvider( providers: [ // Repositories... ], child: MultiBlockProvider( providers: [ // Providers... ], child: // Main application ),).
In this structure, the MultiRepositoryProvider
wraps the MultiBlockProvider
, allowing providers to access repositories. This layered architecture follows the repository design pattern, where:
This clear separation of responsibilities makes the application easier to maintain and scale as it grows in complexity.
Implementing multiple vendors and repositories is a powerful technique for building robust and maintainable applications. By clearly separating responsibilities, we can create code that is more organized and easier to understand. Have you implemented this architecture in your projects? Share your experience in the comments.
Contributions 0
Questions 0
Want to see more contributions, questions and answers from the community?