Cequiel Cequiel - 4 months ago 15
Dart Question

Dart: access the caller instance from a function

How could I access the "caller" instance from a function. The following code throws a syntax error:

// Error: Local variables cannot be referenced before they are declared
Function listener = (Event event) {
print(listener);
};


I would like to access the "listener" variable from inside the function. Thanks.

Answer
Function listener;
listener = (Event event) {
  print(listener);
}