// OK, it works!
void global_1() => global_2();
void global_2() => global_1();
void main() {
// ERROR Local variable 'local_2' can't be referenced before it is declared.
void local_1() => local_2(); // <=== ERROR
void local_2() => local_1();
}
The compiler said "The local variable can't be reference before it is declared"
But why global functions can call each other recursively but local functions can not?
I need to know WHY and some good workarounds for this situation.
I suspect it depends on scope.
global_1
can callglobal_2
because those are both valid for the duration of the app. Butlocal_2
doesn't exist until it is declared, which is after it is used.