Ravi Teja Gudapati
Ravi Teja Gudapati

Reputation: 2869

Dart: Transforming a command line application

Is it possible to run transformer on a command line application before running it?

For example, if I have a class that mixes in Observable class. And I would like to transform it so that dirtCheck is transformed into ChangeNotifier.

holder.dart

class Member extends Object with ChangeNotifier {
  @observable
  String name = "";
}

class Holder extends Object with ChangeNotifier {
  Holder() {
  }

  @observable
  Member member = new Member();
}

pubspec.yml

transformers:
- observe:
  files:
    - bin/models/holder.dart

If I run this application from IntelliJ IDE, it doesn't seem to run the transformer on it before executing main.dart.

Thanks.

Upvotes: 1

Views: 57

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657058

Transfomers are not applied to command line apps. Only code that is served using pub serve or pub build runs and applies transformers. Your code should run on the server/command line as is. There is no need to run transformers.

Transformers are used for observe to replace dart:mirrors access by generated code to prevent code bloat for dart2js-generated JS but this is no issue on the command line.

Upvotes: 1

Related Questions