im trying this and it doesnt work:
Future<bool> isGroupNameAvailable(String name) async {
bool result = true;
(await _fireStore.collection("groups").get()).docs.forEach((doc) {
if (name == doc.id) {
result = false;
}
});
return result;
}
FutureBuilder(
future: db!.isGroupNameAvailable(value),
builder: (BuildContext context,
AsyncSnapshot<bool> snap) {
setState(() {
_isGidUnique = snap.data!
? null
: "this group name is taken,try different one";
});
print("*************first" +
_isGidUnique.toString());
return Text("");
},
);
// db!
// .isGroupNameAvailable(value)
// .then((avilible) => setState(() {
// _isGidUnique = avilible
// ? null
// : "this group name is taken,try different one";
// }));
print(_isGidUnique);
return _isGidUnique;
_isGidUnique should be the string "this group name is taken,try different one" but it gets null i think the future builder doesnt work from some reason help :(