how do I slice a string in dart
Example: "+5124343545"
I want to remove the first index(ie. the "+" sign). so output will look like "5124343545"
void main() {
String string = '+5124343545';
string = string.substring(1);
print(string);
}
Output: 5124343545 Or maybe you want to do the following:
void main() {
String string = '+5124343545';
string = string.replaceFirst('+','');
print(string);
}
In the second variant you have no risk to delete number instead plus symbol (if the input variable didn`t have a plus in the first position).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With