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