やりたいこと
hoge/foo/bar/ という文字列から末尾/を取り除き、hoge/foo/barとしたい。
やり方
final str = 'hoge/foo/bar/';
// 末尾'/'の場所を返す
final pos = str.length - 1;
// 最初からposまでの部分文字列を取得
final result = str.substring(0, pos);
print(result);
// hoge/foo/bar
参考
dart - Flutter - Remove String after certain character? - Stack Overflow