I'm getting this error: type 'Future<dynamic>' is not a subtype of type 'FutureOr<String>'
void main() async {
hello();
}
Future<String> hello() async {
return dynamicHello(); // error : type 'Future<dynamic>' is not a subtype of type 'FutureOr<String>'
return dynamicHello().then((value) => value); // working well
}
Future<dynamic> dynamicHello() async {
return 'HELLO';
}
can someone please explain me the difference between return dynamicHello() and return dynamicHello().then((value) => value) above code
I checked the signature on Future is Future then(FutureOr action(T value), {Function onError}). However, I did not clearly understand why "return dynamicHello()" works normally if I make Future<String> dynamicHello().