Discussion:
[dart-misc] Function annotation for field as a class
'Karan Sikka' via Dart Misc
2017-07-12 15:43:25 UTC
Permalink
Hi, I can't find how to properly annotate a function that's a field as a
class.

Say I have

class Configuration {
Function statsGetter;
Configuration(this.statsGetter);
}

Any way I can further annotate Function statsGetter to have input/output
type annotations?
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Matan Lurey
2017-07-12 15:45:04 UTC
Permalink
This was just added to the language in 1.24.0:

https://github.com/dart-lang/sdk/blob/master/CHANGELOG.md#1240---12-06-2017

typedef F = void Function(); // F is the name for a `void` callback.
int Function(int) f; // A field `f` that contains an int->int function.

class A<T> {
// The parameter `callback` is a function that takes a `T` and returns
// `void`.
void forEach(void Function(T) callback);
}

// The new function type supports generic arguments.
typedef Invoker = T Function<T>(T Function() callback);


On Wed, Jul 12, 2017 at 8:43 AM 'Karan Sikka' via Dart Misc <
Post by 'Karan Sikka' via Dart Misc
Hi, I can't find how to properly annotate a function that's a field as a
class.
Say I have
class Configuration {
Function statsGetter;
Configuration(this.statsGetter);
}
Any way I can further annotate Function statsGetter to have input/output
type annotations?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...