quicktype
quicktype copied to clipboard
[FEATURE]: "empty" method in Dart
Consider the following class
import 'dart:convert';
AdminModel adminModelFromJson(String str) =>
AdminModel.fromJson(json.decode(str));
String adminModelToJson(AdminModel data) => json.encode(data.toJson());
class AdminModel {
String profilePicLink;
String firstName;
String lastName;
String phone;
String email;
bool rememberMe;
AdminModel({
required this.profilePicLink,
required this.firstName,
required this.lastName,
required this.phone,
required this.email,
required this.rememberMe,
});
AdminModel copyWith({
String? profilePicLink,
String? firstName,
String? lastName,
String? phone,
String? email,
bool? rememberMe,
}) =>
AdminModel(
profilePicLink: profilePicLink ?? this.profilePicLink,
firstName: firstName ?? this.firstName,
lastName: lastName ?? this.lastName,
phone: phone ?? this.phone,
email: email ?? this.email,
rememberMe: rememberMe ?? this.rememberMe,
);
factory AdminModel.fromJson(Map<String, dynamic> json) => AdminModel(
profilePicLink: json["profile_pic_link"],
firstName: json["first_name"],
lastName: json["last_name"],
phone: json["phone"],
email: json["email"],
rememberMe: json["remember_me"],
);
Map<String, dynamic> toJson() => {
"profile_pic_link": profilePicLink,
"first_name": firstName,
"last_name": lastName,
"phone": phone,
"email": email,
"remember_me": rememberMe,
};
factory AdminModel.empty() => AdminModel(
profilePicLink: '',
firstName: '',
lastName: '',
phone: '',
email: '',
rememberMe: false,
);
}
In the above class there is an "empty()" method which has been created using AI. If there was a feature which created this method in one click, it would be very convenient.
Thanks.