parse static method
Analiza una cadena siguiendo reglas y devuelve un modelo o estructura con significado
Implementation
static List<TLV> parse(String value){
try {
String unformatedString = value;
final List<TLV> segmentedData = [];
while(unformatedString.isNotEmpty){
final tag = int.parse(unformatedString.substring(0, 2));
final length = int.parse(unformatedString.substring(2, 4));
final value = unformatedString.substring(4, 4+length);
segmentedData.add(TLV(tag: tag, length: length, value: value));
unformatedString = unformatedString.substring(4+length);
//debugPrint('TAG ${tag}, LENGTH: ${length}, VALUE: ${value}, NEWTLV: ${unformatedString}');
debugPrint('TAG ${tag}, LENGTH: ${length}, VALUE: ${value}');
}
return segmentedData;
} catch (e) {
debugPrint('EmvParser Error parsing data: ${e.toString()}. String type EMV standard malformed or incompatible');
throw Exception('EmvParser Error parsing data: ${e.toString()}');
}
}