build_utils 0.0.1
build_utils: ^0.0.1 copied to clipboard

Dart native

A bunch of classes, helpers, generators and things to work with package:build with ease

build_utils #

A package with a bunch of classes, helpers, generators and things to work with package:build with ease

Builders #

Abstract classes of builders that contains a function to override that should return the output of the file given by parameter:

BuilderMISO #

A Builder with Multiple Input, Single Output strategy that produces its output through calling the following function:

FutureOr<String> buildOutput(Set<AssetId> inputs);

In there you should process the inputs for obtaining the Single Output which contents will be returned by the function.

BuilderMIMO #

A Builder with Multiple Input, Multiple Output strategy that produces its Multiple Outputs by calling the following function once per output provided

FutureOr<String> buildOutputFor(String outputPath, Set<AssetId> inputs);

where outputPath will contain the path of the file being generated in the call to the function and inputs will be the same as with MISO builders

Analyzer builders #

As an extension for the above mentioned builders, the Analyzer Builders include in their functions a second one for performing the analysis of the code with the analyzer package. The function to implement is this:

FutureOr<Map> analysisResultsFor(
      AssetId asset, LibraryElement library, Resolver resolver);

In there you should generate a map containing the data you need from the analysis done of the asset provided with the library and resolver derived of it. It will be used later in the respective function for building.

BuilderAnalyzerMISO #

The analyzer equivalent of the MISOBuilder which function is the following:

FutureOr<String> buildOutputWithAnalysis(Map<AssetId, Map> inputsWithAnalysis);

In there you should process the inputWithAnalysis (a map with the input assets matched with their respective previously analyzed) for obtaining the Single Output which contents will be the returned by the function.

BuilderAnalyzerMIMO #

This is the same as with the above builder except that the function will be called once for every output, which path will be provided by parameter.

FutureOr<String> buildOutputWithAnalysisFor(
      String outputPath, Map<AssetId, Map> inputsWithAnalysis);

source_gen #

This package also provides helpers for the source_gen package

ClassPartGenerator #

It's an abstract class that should be instantiated with a fuction for checking if the part file should be generated or not. That function should follow this type:

typedef ShouldGenerateForFuction = bool Function(ClassElement element);

In case it returns true the implementation of the following function will be run:

FutureOr<String> partCode(ClassElement element);

and the output will be the source of the part file generated.

As an example, a part generator that finds private classes and creates a part file of them with the comment of the class found should be like this:

class ExampleClassPartGenerator extends ClassPartGenerator {
  ExampleClassPartGenerator(ShouldGenerateForFuction checkingFn)
      : super(checkingFunction: checkingFn);

  FutureOr<String> partCode(ClassElement element) {
    return '//Found class: ${}';

// The file of this function may/should be referenced by build.yaml 
Builder exampleBuilder() {
  ShouldGenerateForFunction fn;
  fn = (e) => e.isPrivate;
  return PartBuilder([ExampleClassPartGenerator(fn)], '.g.dart');

pub points

A bunch of classes, helpers, generators and things to work with package:build with ease



API reference





analysis_utils, analyzer, build, build_test, dart_style, glob, meta, packages, path, source_gen


Packages that depend on build_utils