Here I have defined a method definition with optional named parameter.
class PostBuilder extends StatefulWidget {
final Future<List<Submission>> Function({String? next}) postFetcher;
...
...
}
I can able to invoke that function as expected like below.
class _PostBuilderState extends State<PostBuilder> {
...
...
_fetch() async {
var posts = await widget.postFetcher();
// or
var posts = await widget.postFetcher(next: _items.getLast()?.name);
}
But unfortunately, I cannot figure our how to use it properly and don't know the correct syntax.
PostBuilder((next) => getPosts(next))
This is syntax error that is being thrown by the compiler
error: The argument type 'Future<List<Submission>> Function(dynamic)' can't be assigned to the parameter type 'Future<List<Submission>> Function({String? next})'. (argument_type_not_assignable)