parse static method
Implementation
static Map<String, String> parse(String text, UCodeFormat format) {
final UCodeValueType type = typeOf(text, format);
switch (type) {
case UCodeValueType.wifi:
return _fields(text.substring(5), <String, String>{"S": "ssid", "T": "security", "P": "password", "H": "hidden"});
case UCodeValueType.contact:
if (text.toUpperCase().startsWith("MECARD:")) {
return _fields(text.substring(7), <String, String>{"N": "name", "TEL": "phone", "EMAIL": "email", "ADR": "address", "URL": "url", "NOTE": "note"});
}
return _vcard(text);
case UCodeValueType.geo:
final List<String> parts = text.substring(4).split(RegExp("[,?]"));
return <String, String>{
if (parts.isNotEmpty) "latitude": parts[0],
if (parts.length > 1) "longitude": parts[1],
if (parts.length > 2) "altitude": parts[2],
};
case UCodeValueType.phone:
return <String, String>{"number": text.substring(4)};
case UCodeValueType.email:
if (text.toUpperCase().startsWith("MAILTO:")) return <String, String>{"address": text.substring(7)};
return _fields(text.substring(7), <String, String>{"TO": "address", "SUB": "subject", "BODY": "body"});
case UCodeValueType.sms:
final List<String> parts = text.split(":");
return <String, String>{
if (parts.length > 1) "number": parts[1],
if (parts.length > 2) "message": parts.sublist(2).join(":"),
};
case UCodeValueType.url:
return <String, String>{"url": text};
case UCodeValueType.product:
case UCodeValueType.isbn:
return <String, String>{"code": text};
case UCodeValueType.text:
case UCodeValueType.calendar:
case UCodeValueType.iban:
case UCodeValueType.upiPayment:
case UCodeValueType.unknown:
return <String, String>{"text": text};
}
}