Мне нужно конвертировать Future <bool>
в bool
. Я знаю, что это можно сделать с then
и await
, но как?
class MyHomeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool isLogin;
checkDatabase().then((onValue){
isLogin = onValue;
});
if(isLogin) return HomePageScreen();
if(!isLogin) return SignInScreen();
}
Future<bool> checkDatabase() async{
Directory directory = await getApplicationDocumentsDirectory();
String path = directory.path + 'koca.db';
return databaseExists(path);
}
}