How to reverse the order of a String in Dart?

Asked

Viewed 418 times

-1

I know that in other languages have methods to get the inverse of a String and I’ve searched Dart, but I’m not finding anything.

I’m doing like this:

String inverter(String v) {
   String inverso ='';
   for (int i = v.length; i >= 1; i--) {
     inverso += v.substring(i-1, i);
   }
   return inverso;
}

but it’s hard to have that in the code.

1 answer

2


  • that’s what I was looking for, thanks for the help, and as for the 'complicated', it’s that I had to have this bit in my code and I knew I should have something ready for it like you showed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.