34 lines
833 B
Dart
34 lines
833 B
Dart
// Description: 验证码渠道枚举类
|
|
class ValidationCodeChannel {
|
|
static const sms = ValidationCodeChannel('1', '短信');
|
|
static const email = ValidationCodeChannel('2', '邮箱');
|
|
|
|
final String value;
|
|
final String label;
|
|
|
|
const ValidationCodeChannel(this.value, this.label);
|
|
|
|
// 支持通过字符串值查找枚举实例
|
|
static ValidationCodeChannel? fromValue(String? value) {
|
|
return {
|
|
'1': sms,
|
|
'2': email,
|
|
}[value];
|
|
}
|
|
|
|
// 支持 toString() 直接输出 value
|
|
@override
|
|
String toString() => value;
|
|
|
|
// 可选:支持 == 比较
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is ValidationCodeChannel &&
|
|
runtimeType == other.runtimeType &&
|
|
value == other.value;
|
|
|
|
@override
|
|
int get hashCode => value.hashCode;
|
|
}
|