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

model extends Equatable,why not #187

Open
wowhoonet opened this issue Sep 24, 2019 · 1 comment
Open

model extends Equatable,why not #187

wowhoonet opened this issue Sep 24, 2019 · 1 comment

Comments

@wowhoonet
Copy link

No description provided.

@wowhoonet
Copy link
Author

`class BaseUser extends Equatable {
String nick;
int uid;
String avatar;
int gender;
int age;

BaseUser({this.nick, this.uid, this.avatar, this.gender, this.age}): super([nick, uid, avatar, gender, age]);

Map<String, dynamic> toJson() => serializer.toMap(this);

static final serializer = BaseUserSerializer();
static BaseUser fromMap(Map map) => serializer.fromMap(map);
static BaseUser fromString(String source) {
var map = json.decode(source);
return map is Map ? fromMap(map) : null;
}

String toString() => toJson().toString();
}`

but base_user.jser.dart method(frommap)
BaseUser fromMap(Map map) { if (map == null) return null; final obj = BaseUser(); obj.nick = map['nick'] as String; obj.uid = map['uid'] as int; obj.avatar = map['avatar'] as String; obj.gender = map['gender'] as int; obj.age = map['age'] as int; return obj; }

why ---> obj.props.addAll(iterable)

sorry My English is so poor~~

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

1 participant