v0.5.9
0.5.9
- 
Update the minimum Dart SDK to 1.22.1.
- 
Deprecated builder.dart: importsource_gen.dartinstead.
- 
Added TypeChecker, a high-level API for performing static type checks:import 'package:analyzer/dart/element/type.dart'; import 'package:source_gen/source_gen.dart'; void checkType(DartType dartType) { // Checks compared to runtime type `SomeClass`. print(const TypeChecker.forRuntime(SomeClass).isExactlyType(dartType)); // Checks compared to a known Url/Symbol: const TypeChecker.forUrl('package:foo/foo.dart#SomeClass'); // Checks compared to another resolved `DartType`: const TypeChecker.forStatic(anotherDartType); } 
- 
Failing to add a librarydirective to a library that is being used as a
 generator target that generates partial files (part of) is now an explicit
 error that gives a hint on how to name and fix your library:> Could not find library identifier so a "part of" cannot be built. > > Consider adding the following to your source file: > > "library foo.bar;" In Dart SDK >=1.25.0this can be relaxed aspart ofcan refer to a path.
 To opt-in,GeneratorBuildernow has a new flag,requireLibraryDirective.
 Set it tofalse, and also set yoursdkconstraint appropriately:sdk: '>=1.25.0 <2.0.0' 
- 
Added LibraryReader, a utility class forLibraryElementthat exposes
 high-level APIs, includingfindType, which traversesexportdirectives
 for publicly exported types. For example, to findGeneratorfrom
 package:source_gen/source_gen.dart:void example(LibraryElement pkgSourceGen) { var library = new LibraryReader(pkgSourceGen); // Instead of pkgSourceGen.getType('Generator'), which is null. library.findType('Generator'); } 
- 
Added ConstantReader, a high-level API for reading from constant (static)
 values from Dart source code (usually represented byDartObjectfrom the
 analyzerpackage):abstract class ConstantReader { factory ConstantReader(DartObject object) => ... // Other methods and properties also exist. /// Reads[ field] from the constant as another constant value. ConstantReader read(String field); /// Reads [field] from the constant as a boolean. /// /// If the resulting value is `null`, uses [defaultTo] if defined. bool readBool(String field, {bool defaultTo()}); /// Reads [field] from the constant as an int. /// /// If the resulting value is `null`, uses [defaultTo] if defined. int readInt(String field, {int defaultTo()}); /// Reads [field] from the constant as a string. /// /// If the resulting value is `null`, uses [defaultTo] if defined. String readString(String field, {String defaultTo()}); }