barrel_files 0.1.1 copy "barrel_files: ^0.1.1" to clipboard
barrel_files: ^0.1.1 copied to clipboard

Generate barrel files for Dart and Flutter packages with build_runner based on code annotations

example/README.md

  1. Add dependency:
# pubspec.yaml

name: example_package

dependencies:
  barrel_files_annotation:
  ...

dev_dependencies:
  barrel_files: 
  build_runner:
  ...
  1. Annotate public top elements:
// lib/src/example_input.dart

import 'package:barrel_files_annotation/barrel_files_annotation.dart';

@includeInBarrelFile
class ExampleClass {}

@includeInBarrelFile
const exampleGlobalConst = 0;

@includeInBarrelFile
enum ExampleEnum {one, two, three}

@includeInBarrelFile
String exampleFunction() => 'example';

@includeInBarrelFile
typedef ExampleTypeDef = void Function(int i);
  1. Run code generation:
dart run build_runner build --delete-conflicting-outputs
  1. Have the barrel file generated:
// lib/example_package.dart

// GENERATED CODE - DO NOT MODIFY BY HAND

export 'package:example_package/src/example_input.dart'
    show
        ExampleClass,
        ExampleEnum,
        ExampleTypeDef,
        exampleFunction,
        exampleGlobalConst;
23
likes
160
pub points
38%
popularity

Publisher

verified publisherleushchenko.com

Generate barrel files for Dart and Flutter packages with build_runner based on code annotations

Repository (GitHub)
View/report issues

Topics

#barrel-files #build-runner #codegen

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, barrel_files_annotation, build, code_builder, dart_style, dartx, file, glob, source_gen, yaml

More

Packages that depend on barrel_files