Skip to content

Instantly share code, notes, and snippets.

@epatel
Created March 23, 2024 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epatel/6dd52de22726e36999d165a9862f8f40 to your computer and use it in GitHub Desktop.
Save epatel/6dd52de22726e36999d165a9862f8f40 to your computer and use it in GitHub Desktop.
Local var life
Future<void> repeat(void Function() repeat) async {
while (true) {
await Future.delayed(Duration(seconds: 1));
repeat();
}
}
void test() {
int a = 7;
repeat(() {
print('Here! $a');
});
repeat(() {
a += 1;
});
a = 5;
}
void main() {
print('Start');
test();
print('End');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment