Solved: Function and Function()

Question

Asked by Jaszczurga on November 15, 2021 (source).

What is difference between Function and Function() in Dart/Flutter? for example in such a code final Function x; final Function() x;

Answer

Question answered by jamesdlin (source).

As stated in the Function documentation, it is:

The base class for all function types.

A variable declared with type Function therefore can be assigned any function. However, you won't get any type-safety when invoking it.

Meanwhile a Function() type is a function with an unspecified (i.e., dynamic) return type and that takes zero arguments.

DART FLUTTER
SHARE: