Darshan Koirala
Darshan Koirala

Reputation: 45

How to delete characters from last in a in string in dart?

I want to remove a character from a string say String A = "Something" Here, I want to make a function that returns "Somethin". Please Help.

Upvotes: 1

Views: 4049

Answers (2)

siva karthikayan
siva karthikayan

Reputation: 1

void removeLastCharacter() {
  String str = "Something."; // input : "Something."
  String result = str.replaceRange(res.split("").length - 1, null, "");
  print(result); // output: "Something"
}

Upvotes: 0

Raine Dale Holgado
Raine Dale Holgado

Reputation: 3460

void removeLastString() {
  String str = "Something";
  String result = str.substring(0, str.length - 1);
  print(result);
}

Upvotes: 9

Related Questions