Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing trailing slash in a String

Tags:

flutter

dart

Some users type https://google.com/ and some users type https://google.com

How to check If user type with slash or not? If user type with a slash How to remove slash?


1 Answers

var str = 'https://google.com/';
if (str.endsWith('/')) str = str.substring(0, str.length - 1);