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

toJson()方法写法错误! #3

Closed
azhengyongqin opened this issue May 17, 2019 · 1 comment
Closed

toJson()方法写法错误! #3

azhengyongqin opened this issue May 17, 2019 · 1 comment

Comments

@azhengyongqin
Copy link

toJson()方法写法错误,会造成 jsonEncode(user) 这样的用法报错!

使用对象时错误如下:

User user = new User("夏目友人帐",'1023007219@qq.com');
print(jsonEncode(user));

image

使用插件自动生产的 toJson()代码如下:

Map<String, dynamic> toJson(User instance) => _$UserToJson(instance);

应该改为:

Map<String, dynamic> toJson() => _$UserToJson(this);
@LuodiJackShen
Copy link
Owner

感谢提醒,这个估计是json_seriliazble升级导致的,现已经修复了,请升级到1.5版本。

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

2 participants