[Solved] Flutter error: type ‘Future‘ is not a subtype of type ‘String?’

2022/09/14 23:21

Error

type ‘Future<dynamic>’ is not a subtype of type ‘String?’

Solution

To receive the value from the future function/await, we need to user var type varaible.

Because the Future function returns actually Future type data. Therefore, we need var type variable to receive it.

More specifically, Future type data will change to String/int/List/Map etc. type data once the data loading is finished. We need var to handle with Future<String> and String (for example, the data type from the Future function is String).

 

Leave a Reply

Back to top