Error when running 'serializer build' in jaguar_serializer

寵の児 提交于 2019-12-08 06:17:43

问题


I'm trying to use jaguar_serializer to convert my json string to its corresponding model object. I followed the steps as described in https://github.com/Jaguar-dart/jaguar_serializer. However, I keep getting this error when I run 'serializer build':

'package:jaguar_generator_config/src/generator.dart': error: line 17: illegal implicit access to receiver 'this' _config = loadYaml(new File(configFileName).readAsStringSync());

Here is my user.dart model:

library models.user;

import 'package:jaguar_serializer/serializer.dart';

part 'user.g.dart';

@GenSerializer()
class UserJsonSerializer extends Serializer<User> with _$UserJsonSerializer {
  User createModel() => new User();
}

/// User model
class User {
  String name;
  int age;
}

And here is my serializer.yaml file:

serializers:
# Add files with your serializable class here.
- lib/models/user.dart

The library version of the serializer is

jaguar_serializer: ^0.3.0


回答1:


if you are using the last version (0.3.7)

The serializer.yaml file is optional but we recommand to use it for large projects.

Don't forget to update the package if necessary

pub global activate jaguar_serializer

if it still does not work, try to clean the yaml file a little bit. Remove the comment and reformat the yaml.

serializers:
  - lib/models/user.dart


来源:https://stackoverflow.com/questions/44634860/error-when-running-serializer-build-in-jaguar-serializer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!