flutterdartphone-number

How to hide half digits of phone number with star format in flutter?


I want to to hide last 7 digits of phone number like below image.

enter image description here


Solution

  • Here, I resolved it by myself

    String number="=+911234567890"
    
    String newNumber=number;
    
    String replaceCharAt(String oldString, int index, String newChar) {
           return oldString.substring(0, index) + newChar + oldString.substring(index + 1);
         }
    
    
       for(int i=6; i<number.length;i++){
             newNumber = replaceCharAt(newNumber, i, "*") ; 
             print("PHONE_NUMBER_LOOP:$newNumber");
    
        }
    
       print("FinalNumber:$newNumber");