Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user file with @required fields in the parameter are not getting generated properly #169

Open
noisytempo opened this issue Jan 14, 2019 · 2 comments

Comments

@noisytempo
Copy link

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
Copy link
Contributor

jaumard commented Jan 14, 2019

Wrong repo, should be under jaguar_serializer I guess :)

@tejainece tejainece transferred this issue from Jaguar-dart/client Jan 14, 2019
@tejainece
Copy link
Member

@noisytempo I will fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants