function as parameter with generic object return type in dart

609

That is not valid syntax. You probably meant:

final Future<PageableModel<T>> Function(String?) elementBuilder;
Share:
609
Donatic
Author by

Donatic

Updated on January 04, 2023

Comments

  • Donatic
    Donatic over 1 year

    I have a function defined as

    final Function<Future<PageableModel<T>>>(String?) elementBuilder;
    

    The compiler shows a compile error at "Future": Expected to find '>'. Is it possible in Dart to define a generic object as the return type of a function defined as variable.

  • jamesdlin
    jamesdlin almost 2 years
    @Donatic How is that awkward syntax? Function return types in Dart normally go to the left of the function declaration. It's also not any longer than what you originally tried.