Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Created April 24, 2022 17:46
Show Gist options
  • Save felipecastrosales/f9c053bb7146b65e356a8bb5918de291 to your computer and use it in GitHub Desktop.
Save felipecastrosales/f9c053bb7146b65e356a8bb5918de291 to your computer and use it in GitHub Desktop.
Closure in Dart
// ignore_for_file: prefer_function_declarations_over_variables
void main() {
String message = 'Interessante';
print('Antes: $message');
Function showMessage = () {
message = 'Boto fé';
print('Depois: $message');
};
showMessage();
Function present = () {
String welcome = 'Dale';
print('Antes: $welcome');
Function say = () {
welcome = 'Welcome';
print('Depois: $welcome');
};
return say;
};
Function speak = present();
speak();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment