-1
When calling the method callReadTotal(), the global variable tot receives the value and it prints without problems its result within it. However, in the class ThemesList called it, the variable receives null.
Could someone tell me what’s missing there? Thanks in advance.
callReadTotal() async {
await firestoreInstance.collection("causas").get().then((value) {
tot = value.docs.length;
});
print(tot);
}
int tot;
FirebaseFirestore firestoreInstance = FirebaseFirestore.instance;
class ThemesList extends StatelessWidget {
List<FlatButton> _getButtonBar(context) {
callReadTotal(); //chamando o método
print(tot); //recebe sempre null.
.
.
.