Profile cover photo
Profile photo
Everything around Dart!
Everything around Dart!


Post has attachment
v0.6.0 of source_gen



source_gen provides utilities for automated source code generation for Dart:

A tool for generating code that is part of your Dart project.

A framework for creating and using multiple code generators in a single project.

A convention for human and tool generated Dart code to coexist with clean separation.

It's main purpose is to expose a developer-friendly API on top of lower-level packages like the analyzer or build. You don't have to use source_gen in order to generate source code; we also expose a set of library APIs that might be useful in your generators.

Quick Start Guide

Because source_gen is a package, not an executable, it should be included as a dependency in your project. If you are creating a generator for others to use (for example, a JSON serialization generator) or a library that builds on top of source_gen include it in your pubspec dependencies:


If you're only using source_gen in your own project to generate code, and then you publish that code (generated code included), then you can simply add as a dev_dependency:


Once you have source_gen setup, you should reference the examples below.


Given a library example.dart with an Person class annotated with @JsonSerializable:

library source_gen.example;

import 'package:source_gen/generators/json_serializable.dart';
part 'example.g.dart';

class Person extends Object with _$PersonSerializerMixin {
final String firstName, middleName, lastName;

final DateTime dateOfBirth;

Person(this.firstName, this.lastName, {this.middleName, this.dateOfBirth});

factory Person.fromJson(json) => _$PersonFromJson(json);

source_gen creates the corresponding part example.g.dart:

part of source_gen.example;

Person _$PersonFromJson(Map json) => new Person(
json['firstName'], json['lastName'],
middleName: json['middleName'],
dateOfBirth: json['date-of-birth'] == null
? null
: DateTime.parse(json['date-of-birth']));

abstract class _$PersonSerializerMixin {
String get firstName;
String get middleName;
String get lastName;
DateTime get dateOfBirth;
Map<String, dynamic> toJson() => <String, dynamic>{
'firstName': firstName,
'middleName': middleName,
'lastName': lastName,
'date-of-birth': dateOfBirth?.toIso8601String(),

See the example code in the source_gen GitHub repo.

Creating a generator

Extend the Generator class to plug into source_gen.

Trivial example

Included generators

Running generators

source_gen is based on the build package.

See build.dart and watch.dart in the tool directory. Both reference tool/phases.dart, which contains information mapping source_gen generators to target files.


What is the difference between source_gen and build?

Build is a platform-agnostic framework for Dart asset or code generation that is pluggable into multiple build systems including barback (pub/dart transformers), bazel, and standalone tools like build_runner. You could also build your own.

Meanwhile, source_gen provides an API and tooling that is easily usable on top of build to make common tasks easier and more developer friendly. For example the GeneratorBuilder class wraps one or more Generator instances to make a Builder.

What is the difference between source_gen and transformers?

Dart transformers are often used to create and modify code and assets as part of a Dart project.

Transformers allow modification of existing code and encapsulates changes by having developers use pub commands – run, serve, and build. Unfortunately the API exposed by transformers hinder fast incremental builds, output caching, and predictability, so we introduced builders as part of package:build.

Builders and source_gen provide for a different model: outputs must be declared ahead of time and code is generated and updated as part of a project. It is designed to create part or standalone files that augment developer maintained Dart libraries. For example AngularDart uses build and source_gen to "compile" HTML and annotation metadata into plain .dart code.

Unlike transformers, generated code MAY be checked in as part of your project source, although the decision may vary depending on project needs.

Generated code SHOULD be included when publishing a project as a pub package. The fact that source_gen is used in a package is an implementation detail.
Add a comment...

Post has attachment
v1.2.0 of built_value

Built Values for Dart


Built Values provides:

Immutable value types;

EnumClass, classes that behave like enums;

JSON serialization.

Immutable collections are from built_collection.


built_value for Immutable Object Models

built_value for Serialization

Building a Chat App in Dart

End to End Testing in One Short Second with Dart

Moving Fast with Dart Immutable Values


For an end to end example see the chat example, which was demoed at the Dart Summit 2016. The data model, used both client and server side, uses value types, enums and serialization from built_value.

Simple examples are here.

Codegen is triggered via either a build.dart to do a one-off build or a watch.dart to continuously watch your source and update generated output.

Value Types

Value types are, for our purposes, classes that are considered interchangeable if their fields have the same values.

Common examples include Date, Money and Url. Most code introduces its own value types. For example, every web app probably has some version of Account and User.

Value types are very commonly sent by RPC and/or stored for later retrieval.

The problems that led to the creation of the Built Value library have been discussed at great length in the context of AutoValue for Java.

In short: creating and maintaining value types by hand requires a lot of boilerplate. It's boring to write, and if you make a mistake, you very likely create a bug that's hard to track down.

Any solution for value types needs to allow them to participate in object oriented design. Date, for example, is the right place for code that does simple date manipulation.

AutoValue solves the problem for Java with code generation, and Built Values does the same for Dart. The boilerplate is generated for you, leaving you to specify which fields you need and to add code for the behaviour of the class.

Enum Class

Enum Classes provide classes with enum features.

Enums are very helpful in modelling the real world: whenever there are a small fixed set of options, an enum is a natural choice. For an object oriented design, though, enums need to be classes. Dart falls short here, so Enum Classes provide what's missing!


Constants have name and toString, can be used in switch statements, and are real classes that can hold code and implement interfaces

Generated values method that returns all the enum values in a BuiltSet (immutable set)

Generated valueOf method that takes a String


Built Values comes with JSON serialization support which allows you to serialize a complete data model of Built Values, Enum Classes and Built Collections. The chat example shows how easy this makes building a full application with Dart on the server and client.

Here are the major features of the serialization support:

It fully supports object oriented design: any object model that you can design can be serialized, including full use of generics and interfaces. Some other libraries require concrete types or do not fully support generics.

It allows different object oriented models over the same data. For example, in a client server application, it's likely that the client and server want different functionality from their data model. So, they are allowed to have different classes that map to the same data. Most other libraries enforce a 1:1 mapping between classes and types on the wire.

It requires well behaved types. They must be immutable, can use interface but not concrete inheritance, must have predictable nullability, hashCode, equals and toString. In fact, they must be Enum Classes, Built Collections or Built Values. Some other libraries allow badly behaved types to be serialized.

It supports changes to the data model. Optional fields can be added or removed, and fields can be switched from optional to required, allowing your data model to evolve without breaking compatbility. Some other libraries break compatability on any change to any serializable class.

It's modular. Each endpoint can choose which classes to know about; for example, you can have multiple clients that each know about only a subset of the classes the server knows. Most other libraries are monolithic, requiring all endpoints to know all types.

It's multi language. Support will be come first for Dart, Java and Java/GWT. Many other libraries support a single language only.

It has first class support for validation via Built Values. An important part of a powerful data model is ensuring it's valid, so classes can make guarantees about what they can do. Other libraries also support validation but usually in a less prominent way.

It's pluggable. You can add serializers for your own types, and you can add plugins which run before and after all serializers. This could be used to interoperate with other tools or to add hand coded high performance serializers for specific classes. Some other libraries are not so extensible.

Add a comment...

Post has attachment
v0.1.2 of http2

HTTP/2 for Dart

Note: This is a work in progress and experimental.

See the API docs for more details and sample code.

Features and bugs

Please file feature requests and bugs at the issue tracker.
Add a comment...

Post has attachment
v0.2.3 of gitlab

GitLab API

This is a dart library to communicate with the GitLab API v4.

This is still work in progress. We are happy about Merge Requests!

This library is already in production use, but it is missing a lot of calls and properties.

The calls that are present should be safe to use.

There are still tests missing for a lot of resources though.


Simply add it to your project as a dependency:

gitlab: any


For the full documentation, and usage, please refer to the documentation.


Add a comment...

Post has attachment
v1.0.0 of graphql_parser


Parses GraphQL queries and schemas. Also includes a GraphQLVisitor class.

This library is merely a parser/visitor. Any sort of actual GraphQL API functionality must be implemented by you, or by a third-party package.

Angel framework users should consider package:angel_graphql as a dead-simple way to add GraphQL functionality to their servers.


Add graphql_parser as a dependency in your pubspec.yaml file:

graphql_parser: ^1.0.0


The AST featured in this library is directly based off this ANTLR4 grammar created by Joseph T. McBride:

import 'package:graphql_parser/graphql_parser.dart';

doSomething(String text) {
var tokens = scan(text);
var parser = new Parser(tokens);

// Parse the GraphQL document using recursive descent
var doc = parser.parseDocument();

// Do something with the parsed GraphQL document...
Add a comment...

Post has attachment
v0.0.1 of d_components

A web app that uses AngularDart Components

Generated by Stagehand. See LICENSE.
Add a comment...

Post has attachment
v0.0.21 of np8080

np8080 0.0.21

3rd July 2017

NP8080 is a simple notepad type app for the web with some text processing features. It is lightweight and fast to load. 100% functionality when offline so great for Chromebooks.

I use it daily as a scratchpad, a markdown editor and for notes. Particularly handy when working in the context of a web browser as switching tabs is far smoother than switching applications.

You can try it out here.

Feature requests and pull requests welcome!

Development Details

NP8080 is written in Angular Dart and can be hosted on any web server as it is client-side. Find out more about Dart.

Run tests with:

pub run test test/textprocess_tests.dart -p dartium

Run in development with:

pub serve

Build for deployment with:

pub build release
Add a comment...

Post has attachment
v0.0.23 of jaguar_query


Dialect neutral, fluent Dart DSL to build SQL/NoSQL queries


[ ] DateTime field
Add a comment...

Post has attachment
v0.2.0 of cellular_automata

Cellular Automata

A cellular automata library / playground written in Dart. Happily accepting pull requests! ^_^

Author: jimmyff


Dart Pub:



Generators to seed the simulation

Current renderers:

StageXL: WebGL, fullscreen support

Implemented rules/simulations

Conway's Game of Life


See the demos/ folder for demos. You can try the hosted demos here.


Dartium performance is significantly faster than compiled performance at the moment. Also there are some generator defects that are yet to be resolved. To try and increase use the trust-type-annotations flag in your pubspec:

- $dart2js:
checked: false
minify: true
commandLineOptions: ['--trust-type-annotations', '--trust-primitives']


Add tests

Performance information

Implement additional CA rules (Brain, Voting, WireWorld etc)

Detect stale simulations for reset / next

Playlist of simulations

Transitions for switching between two simulations

Multiple simulations/rule-sets running in a single scene

Generated color palettes

Simulation controls (pause, reset, speed etc)

Interactive mode (edit mode)

Analysis tools (histograms for state counts)

Add an LED Matrix renderer for raspberry pi using GPIO pins

Flutter renderer

CLI renderer

Infinite world size support


Please see the cellular_automata license.
Add a comment...
Wait while more posts are being loaded