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 buildor
pub run build_runner watchfor a standalone package or command-line application
flutter packages pub run build_runner buildor
flutter packages pub run build_runner watchfor a Flutter project
webdev servefor 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:
And if you want to exclude generated files:
Then, from a Dart file in
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 ofdirectives, which is not allowed because they aren't standalone libraries. Unfortunately, the method on
BuildStepfor determining whether or not a file is a library is broken and always returns false. Or more technically a
Futurethat completes with false. Whatever. The point is, it doesn't work and it's dumb.