Convert JSON String to Object in Dart

import 'dart:convert';

void main() {
    var jsonString = '{"name": "name 1", "email": "abc@gmail.com"}';
    Map userMap = jsonDecode(jsonString);
    var user = User.fromJson(userMap);
    print('name: ${user.name}');
    print('email: ${user.email}');
}
  
class User {
    String name;
    String email;
  
    User(this.name, this.email) {
      this.name = name;
      this.email = email;
    }
  
    User.fromJson(Map<dynamic, dynamic> json)
        : name = json['name'],
          email = json['email'];
  
    Map<String, dynamic> toJson() => {
        'name': name,
        'email': email,
    };
}
  
name: name 1
email: abc@gmail.com