How to run `source_gen`?

Viewed 1357

I am currently trying to use built_value in my Flutter project but I am confused on what I need to do...

I put the following lines in my pubspec.yaml (copied from an example project):

dev_dependencies:
  build: ^0.7.0
  build_runner: ^0.3.0
  built_value_generator: ^1.0.0

But, so far, nothing is happening... In this video demonstration you can see that the generated code is updated/regenerated on the fly, while the developer is changing his code.

Do I need to do anything else to have the code generation work? Start some kind of server that watches for changes and trigger code generation? Register source_gen to be run at some point?

EDIT: OK, so now I have a tool folder next to the lib folder. The tool folder contains both build.dart and watch.dart, both changed to match the package name: in my pubspec.yaml. The lib folder contains a file user.dart, which I copied from this tutorial.

library user;

import 'package:built_value/built_value.dart';

part 'user.g.dart';

abstract class User implements Built<User, UserBuilder> {
  String get name;

  @nullable
  String get nickname;

  User._();

  factory User([updates(UserBuilder b)]) = _$User;
}

Shouldn't I now be seeing a user.g.dart file appear in lib that contains the generated code? There's nothing wrong with the glob pattern, is it?

EDIT 2: This is the output of flutter --version:

dmta@elite:~/flutter$ flutter --version
Flutter • channel master • https://github.com/flutter/flutter.git
Framework • revision e65d47d4ba (11 hours ago) • 2017-05-15 12:40:20 -0700
Engine • revision 7dd359e165
Tools • Dart 1.23.0-dev.11.11
1 Answers
Related