[Flutter + Android Studio]
페이지 정보
작성자 sbLAB 댓글 0건 조회 426회 작성일 24-02-26 08:06본문
- Dart Data Class / Flutter-Toolkit
https://velog.io/@jsoh/Flutter-Android-Studio-%ED%94%8C%EB%9F%AC%EA%B7%B8%EC%9D%B8
[Dart Data Class 로 생성 예제]
/// UserModel 데이타모델
class UserModel {
String? email;
String? password;
String? ip;
String? tk;
//<editor-fold desc="Data Methods">
UserModel({
this.email,
this.password,
this.ip,
this.tk,
});
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is UserModel &&
runtimeType == other.runtimeType &&
email == other.email &&
password == other.password &&
ip == other.ip &&
tk == other.tk);
@override
int get hashCode => email.hashCode ^ password.hashCode ^ ip.hashCode ^ tk.hashCode;
@override
String toString() {
return 'UserModel{' + ' email: $email,' + ' password: $password,' + ' ip: $ip,' + ' tk: $tk,' + '}';
}
UserModel copyWith({
String? email,
String? password,
String? ip,
String? tk,
}) {
return UserModel(
email: email ?? this.email,
password: password ?? this.password,
ip: ip ?? this.ip,
tk: tk ?? this.tk,
);
}
Map<String, dynamic> toMap() {
return {
'email': this.email,
'password': this.password,
'ip': this.ip,
'tk': this.tk,
};
}
factory UserModel.fromMap(Map<String, dynamic> map) {
return UserModel(
email: map['email'] as String,
password: map['password'] as String,
ip: map['ip'] as String,
tk: map['tk'] as String,
);
}
//</editor-fold>
}
댓글목록
등록된 댓글이 없습니다.