user file with @required fields in the parameter are not getting generated properly
Opened this issue · 2 comments
noisytempo commented
part 'device.jser.dart';
class Device {
String uuid;
//Name of the device
String name;
Device({@required this.uuid, this.name});
Map<String, dynamic> toJson() => serializer.toMap(this);
static final serializer = DeviceSerializer();
static Device fromMap(Map map) => serializer.fromMap(map);
String toString() => toJson().toString();
}
@GenSerializer()
class DeviceSerializer extends Serializer<Device> with _$DeviceSerializer {}
generated file is:
part of 'device.dart';
// **************************************************************************
// JaguarSerializerGenerator
// **************************************************************************
abstract class _$DeviceSerializer implements Serializer<Device> {
@override
Map<String, dynamic> toMap(Device model) {
if (model == null) return null;
Map<String, dynamic> ret = <String, dynamic>{};
setMapValue(ret, 'uuid', model.uuid);
setMapValue(ret, 'name', model.name);
return ret;
}
@override
Device fromMap(Map map) {
if (map == null) return null;
final obj = new Device(); //it should be final obj = new Device(uuid:'');
obj.uuid = map['uuid'] as String;
obj.name = map['name'] as String;
return obj;
}
}
jaumard commented
Wrong repo, should be under jaguar_serializer I guess :)
tejainece commented
@noisytempo I will fix this.