# Dart function — Recursive Functions

Feb 12, 2022

--

*recursive function is a function that calls itself*. A recursive function is used for repeating code. If the state of the function does not change, and it has no preset exit condition that is reached, a recursive call can turn into an infinite loop.

`void forever() { `

forever();

}

forever() is indeed an infinite loop. Here is a recursive function that will repeatedly add one String to

another String.

`String addOn(String original, String additional, int times) { `

if (times <= 0) { // exit condition to end "recursive loop"

return original;

}

return addOn(original + additional, additional, times - 1);

// recursive call

}

Read more : https://softwarezay.com/notes/396_dart-function-recursive-functions