Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/angeloavv/barrel
Generate barrel files for each folder for Dart and Flutter projects
https://github.com/angeloavv/barrel
Last synced: about 2 months ago
JSON representation
Generate barrel files for each folder for Dart and Flutter projects
- Host: GitHub
- URL: https://github.com/angeloavv/barrel
- Owner: AngeloAvv
- License: mit
- Created: 2024-11-05T13:50:45.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2024-11-05T14:18:14.000Z (about 2 months ago)
- Last Synced: 2024-11-05T14:53:19.967Z (about 2 months ago)
- Language: Dart
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Barrel
Generate barrel files for each folder for Dart and Flutter projects. A barrel file is a file that exports all the files in a directory. This is useful when you have a lot of files in a directory and you want to import them all in one go.
[![Pub](https://img.shields.io/pub/v/barrel_generator.svg)](https://pub.dev/packages/barrel_generator)
![Dart CI](https://github.com/AngeloAvv/barrel/workflows/Dart%20CI/badge.svg)
[![Star on GitHub](https://img.shields.io/github/stars/AngeloAvv/barrel.svg?style=flat&logo=github&colorB=deeppink&label=stars)](https://github.com/AngeloAvv/barrel)
[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)
[![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/AngeloAvv)If you want to support this project, please leave a star, share this project, or consider donating through [Github Sponsor](https://github.com/sponsors/AngeloAvv).
## Getting Started
Add the following dependencies to your `pubspec.yaml`:
```yaml
dependencies:
barrel_annotation: ^1.0.0dev_dependencies:
build_runner: ^2.4.13
barrel_generator: ^1.0.0
```Decorate one of your files placed in the source root of your project with the `BarrelConfig` annotation:
```dart
import 'package:barrel_annotation/barrel_annotation.dart';@BarrelConfig(exclude: [
'lib/lib.barrel.dart',
])
void main() {
print('Hello, World!');
}
```Run the following command to generate the barrel files:
```bash
dart run build_runner build --delete-conflicting-outputs
```## Features
- [x] Generate barrel files for each folder
- [x] Exclude files and directories
- [x] Generate barrel files for Flutter projects
- [x] Generate barrel files for Dart projects
- [x] Generate barrel files for packages## Configuration
The `BarrelConfig` annotation has the following properties:
- `exclude`: A list of files and directories to exclude from the barrel file.
## Example
Given the following directory structure:
```
lib/
excluded/
f.dart
g.dart
folder/
subfolder/
a.dart
b.dart
c.dart
example.dart
```With the following configuration:
```dart
import 'package:barrel_annotation/barrel_annotation.dart';@BarrelConfig(exclude: [
'lib/lib.barrel.dart',
'lib/excluded/**',
])
void main() {
print('Hello, World!');
}
```The generated barrel files structure will look like this:
```
lib/
excluded/
f.dart
g.dart
folder/
subfolder/
a.dart
b.dart
c.dart
folder.barrel.dart
example.dart
```The content of `lib/folder/folder.barrel.dart` will be:
```dart
// This file is generated by barrel_generator// Barrel files
export 'subfolder/subfolder.barrel.dart';
// Other files
export 'c.dart';
export 'a.dart';
export 'b.dart';
```## Questions and bugs
Please feel free to submit new issues if you encounter problems while using this library.
If you need help with the use of the library or you just want to request new features, please use
the [Discussions](https://github.com/AngeloAvv/barrel/discussions) section of the
repository. Issues opened as questions will be automatically closed.## License
Barrel is available under the MIT license. See the LICENSE file for more info.