Try to parse to num, fallback to def
def
num toNum({num def = 0}) { if (this == null) return def; return num.tryParse(toString()) ?? def; }