I know about this question. It's not a duplicate because it doesn't mention
typedefs
I have this typedef
:
typedef Prefetcher = Future<void> Function(
MarkdocNode node, PrefetchContext context);
Now I'm trying to define top level functions that comply with the Prefetcher
signature.
but when I do this:
final Prefetcher prefetchTranslatedSentences = (node, context) async {};
I'm getting this warning:
info: Use a function declaration to bind a function to a name. (prefer_function_declarations_over_variables at [anglio_mobile] lib/components/markdown/prefetchers/translated_sentence_prefetcher.dart:3)
I understand that Dart wants me to NOT assign a function to a variable, but rather create a function directly like
prefetchTranslatedSentences(node, context) async {}
but the problem of the above is that there is no guarantee that prefetchTranslatedSentences
will comply with the typedef
How do I create top-level functions that comply with typedefs
without getting this warning?