class Foo { final String? bar; Foo({this.bar}); Map toJson() { return {'bar': bar}; } }