fromValue static method
Parses a CVM from either the numeric or the string form. Returns null
when the value is missing or not recognised.
Implementation
static Cvm? fromValue(Object? value) {
if (value == null) return null;
if (value is num) {
switch (value.toInt()) {
case 0:
return Cvm.unknown;
case 1:
return Cvm.signature;
case 2:
return Cvm.pin;
case 3:
return Cvm.noCvm;
}
return null;
}
switch (value.toString().toUpperCase().replaceAll(' ', '')) {
case 'SIGNATURE':
return Cvm.signature;
case 'PIN':
return Cvm.pin;
case 'NOCVM':
return Cvm.noCvm;
case 'UNKNOWN':
return Cvm.unknown;
}
return null;
}