问题
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