Convert Object to JSON String in Dart

void main() {
    var user = new User("NilPointer", "NilPointer@gmail.com");
    print(user.toJson().toString());
}
  
class User {
    String name;
    String email;
  
    User(this.name, this.email) {
      this.name = name;
      this.email = email;
    }
  
    User.fromJson(Map<String, dynamic> json)
        : name = json['name'],
          email = json['email'];
  
    Map<String, dynamic> toJson() => {
        'name': name,
        'email': email,
    };
}
  
{name: NilPointer, email: NilPointer@gmail.com}