lastFourDigits property

String get lastFourDigits

Last four digits for UI and OTP flows.

Implementation

String get lastFourDigits {
  final n = cardNumber?.replaceAll(RegExp(r'\s'), '');
  if (n != null && n.length >= 4) {
    return n.substring(n.length - 4);
  }
  final d = displayLastFour?.replaceAll(RegExp(r'\D'), '') ?? '';
  if (d.length >= 4) {
    return d.substring(d.length - 4);
  }
  if (d.isNotEmpty) return d;
  return '----';
}