07-21-2023, 09:55 PM
**
Here is a function you can use to reverse strings. It takes an string as input and will use a dart package called split() to extract characters from the given string. Then we can reverse them and join again to make the reversed string.
**
String? stringReverse(String? string) {
if (string != null) {
final output = string.split('').reversed.join();
return output;
}
}
void main() {
String? string = stdin.readLineSync();
print(stringReverse(string));
}
Here is a function you can use to reverse strings. It takes an string as input and will use a dart package called split() to extract characters from the given string. Then we can reverse them and join again to make the reversed string.
**
String? stringReverse(String? string) {
if (string != null) {
final output = string.split('').reversed.join();
return output;
}
}
void main() {
String? string = stdin.readLineSync();
print(stringReverse(string));
}