我无法在这里使用未来布尔值..有什么方法可以在这种情况下使用未来布尔值..或者有没有更好的方法来做到这一点?
Widget _buildRow(String pair) {
final Future<bool> alreadySaved = DBHelper.getAllEmployees().then((value) => value.contains(pair));
print("Already saved $alreadySaved");
print(pair);
return FutureBuilder(
future: DBHelper.getAllEmployees(),
builder: (context, AsyncSnapshot<List<FavrtTableModel>> snapshot) =>
snapshot.connectionState == ConnectionState.waiting ? Center(
child: Icon(Icons.more_horiz),
):IconButton(
icon: new Icon(
alreadySaved ? Icons.favorite : Icons.favorite_border,
color:alreadySaved? Colors.red : Colors.white,
),onPressed: (){
setState(() {
if (alreadySaved) {
_saved.remove(pair);
_deleteEmployee(pair);
} else {
_saved.add(pair);
_insert(pair);
}
});
},
),
);
}