A builder package for automatically exporting Dart files in a project based on globs.
The builder looks for files with the .glex
extension and processes them similarly to gitignore files, except backwards:
- Globs directly listed in the file are included.
- Globs preceded with ! are excluded.
- Exclusions take precedence over inclusions.
- Lines preceded with # are treated as comments and ignored.
Make sure you have this package and build_runner
as dev dependencies, then run
pub run build_runner build
orpub run build_runner watch
for a standalone package or command-line applicationflutter packages pub run build_runner build
orflutter packages pub run build_runner watch
for a Flutter projectwebdev build
orwebdev serve
for a web project
The output file has the extension .g.dart
and simply exports all included files.
A common use case would be an everything.glex
file in the lib
folder of an application package:
**.dart
And if you want to exclude generated files:
!**.g.dart
Then, from a Dart file in lib
:
import 'everything.g.dart';
// Some code that uses other code from elsewhere in your package
- There are no tests. No unit tests. No integration tests. No tests, whatsoever. Where would one even begin writing tests for a builder? (That was a serious question. I have no idea how to automatically test this.)
- Currently, the package will happily export Dart files with
part of
directives, which is not allowed because they aren't standalone libraries. Unfortunately, the method onBuildStep
for determining whether or not a file is a library is broken and always returns false. Or more technically aFuture
that completes with false. Whatever. The point is, it doesn't work and it's dumb.