Skip to content

Instantly share code, notes, and snippets.

@BekNaji
Created March 1, 2023 11:30
Show Gist options
  • Save BekNaji/2161d120f0cadf7a316f2ad50b022590 to your computer and use it in GitHub Desktop.
Save BekNaji/2161d120f0cadf7a316f2ad50b022590 to your computer and use it in GitHub Desktop.
pretty bank code in flutter | dart
void main() {
var item = "12345678911234567891";
print(prettyBankCode(item)); // 1234 5678 9112 3456 7891
}
prettyBankCode(item){
if(item != null && item.length == 20){
var code = item.substring(0,4);
code = code + ' ' + item.substring(4,8);
code = code + ' ' + item.substring(8,12);
code = code + ' ' + item.substring(12,16);
code = code + ' ' + item.substring(16,20);
return code;
}
return item;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment