An open API service indexing awesome lists of open source software.

https://github.com/anhkato/flutter-bloc-clean-architecture

Kickstart your Flutter app with this BLoC Clean Architecture boilerplate. Organized structure, dependency injection, and immutable data classes make development smooth. 🚀🐙
https://github.com/anhkato/flutter-bloc-clean-architecture

android clean-architecture-example dart dartz emulator flutter flutter-bloc flutter-bloc-clean-architecture flutter-bloc-pattern flutter-clean-architecture flutter-clean-architecture-example flutter-ecommerce flutter-example flutter-examples flutter-solid get-it port-adapter tdd

Last synced: 1 day ago
JSON representation

Kickstart your Flutter app with this BLoC Clean Architecture boilerplate. Organized structure, dependency injection, and immutable data classes make development smooth. 🚀🐙

Awesome Lists containing this project

README

        

# Flutter BLoC Clean Architecture Example Project

![GitHub release](https://img.shields.io/github/release/Anhkato/flutter-bloc-clean-architecture.svg)
![GitHub issues](https://img.shields.io/github/issues/Anhkato/flutter-bloc-clean-architecture.svg)
![GitHub stars](https://img.shields.io/github/stars/Anhkato/flutter-bloc-clean-architecture.svg)

## Overview

This repository showcases a Flutter project that demonstrates the use of the BLoC (Business Logic Component) pattern within a clean architecture framework. The project serves as a boilerplate template, making it easy for developers to start building scalable and maintainable applications.

## Table of Contents

- [Features](#features)
- [Getting Started](#getting-started)
- [Project Structure](#project-structure)
- [Usage](#usage)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [Releases](#releases)

## Features

- **Clean Architecture**: Separates concerns into layers, making your code more maintainable.
- **BLoC Pattern**: Utilizes streams and sinks to manage state effectively.
- **Dependency Injection**: Manages dependencies easily, promoting better testability.
- **Freezed**: Simplifies data class creation and immutability.
- **MVVM Architecture**: Follows the Model-View-ViewModel pattern for better UI management.

## Getting Started

To get started with this project, clone the repository and install the required dependencies.

```bash
git clone https://github.com/Anhkato/flutter-bloc-clean-architecture.git
cd flutter-bloc-clean-architecture
flutter pub get
```

### Running the Project

You can run the project using the following command:

```bash
flutter run
```

For more detailed instructions, visit the [Releases](https://github.com/Anhkato/flutter-bloc-clean-architecture/releases) section.

## Project Structure

The project is organized into the following main directories:

```
lib/
├── core/
│ ├── error/
│ ├── usecases/
│ └── utils/
├── features/
│ ├── feature_one/
│ ├── feature_two/
│ └── feature_three/
└── main.dart
```

- **core/**: Contains core functionalities, utilities, and error handling.
- **features/**: Each feature of the application is organized into its own directory.

## Usage

### BLoC Implementation

The BLoC pattern is implemented in each feature directory. For example, in `feature_one`, you will find the following files:

- `feature_one_bloc.dart`: Contains the BLoC class.
- `feature_one_event.dart`: Defines events that the BLoC will handle.
- `feature_one_state.dart`: Defines the states of the feature.

### Example Usage

To use the BLoC in your UI, wrap your widget with a `BlocProvider`:

```dart
BlocProvider(
create: (context) => FeatureOneBloc(),
child: FeatureOneScreen(),
)
```

Then, you can listen to the BLoC's state:

```dart
BlocBuilder(
builder: (context, state) {
if (state is FeatureOneLoading) {
return CircularProgressIndicator();
} else if (state is FeatureOneLoaded) {
return Text(state.data);
}
return Container();
},
)
```

## Testing

This project includes unit tests to ensure that your BLoCs and other components work as expected. You can run the tests using the following command:

```bash
flutter test
```

### Writing Tests

Tests are located in the `test/` directory. Each feature should have its own test files. Use the `mockito` package for mocking dependencies.

```dart
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

class MockRepository extends Mock implements Repository {}

void main() {
// Write your tests here
}
```

## Contributing

Contributions are welcome! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Make your changes and commit them.
4. Push to your branch and create a pull request.

For more detailed contribution guidelines, check the [CONTRIBUTING.md](CONTRIBUTING.md) file.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Releases

For the latest releases, visit the [Releases](https://github.com/Anhkato/flutter-bloc-clean-architecture/releases) section. You can download and execute the files provided there to get started quickly.

## Topics

This project covers a variety of topics relevant to modern Flutter development:

- boilerplate
- boilerplate-application
- boilerplate-code
- boilerplate-template
- clean-architecture
- clean-architecture-boilerplate
- dependency-injection
- flutter-bloc
- flutter-bloc-examples
- flutter-bloc-pattern
- flutter-bloc-patterns
- flutter-freezed
- freezed
- freezed-flutter-api
- mvvm-architecture
- repository-pattern

## Acknowledgments

Thanks to the Flutter community for their contributions and support. Special thanks to the creators of the BLoC pattern and clean architecture principles.

![Flutter Logo](https://flutter.dev/assets/homepage/carousel/slide_1-bg-opaque-7b63c6e7c6f84d2e6d6e2f1a6eaf1b3c.png)

Feel free to explore the project and utilize it in your own applications. Happy coding!