Flutter 报错 Flutter : 'Future <dynamic>' is not a subtype of type bool

Flutter : 'Future <dynamic>' is not a subtype of type bool

这个问题是我在使用flutter shared_preferences的时候,自己默认写了几个存储和读取的字段函数,然后出错了

问题在!

我使用的时候非常耿直 如图

getUserNameInput函数如下 

没错,这就是基本功不扎实啊,没有完全理解掌握Future的用法

正确写法

 

 需要使用await 和 async 关键字 async关键字为外部函数标注关键字

或者还有种方法 

你不想写那么多关键字的话!


原文地址:https://www.cnblogs.com/fengfenghuifei/p/13453195.html