I get a Stack Overflow error but I don't seem to know what's wrong. This is Database class helps me to get FirebaseDatabase information.
import 'package:firebase_database/firebase_database.dart';
import 'User.dart';
import 'dart:async';
class FireDatabase{
FireDatabase();
DatabaseReference userRef = FirebaseDatabase.instance.reference().child("users");
DatabaseReference transactionsRef = FirebaseDatabase.instance.reference().child("transactions");
User user = new User();
getDatabaseUser(String cUid){
userRef.orderByChild(cUid).once().then((DataSnapshot data){
if (data.value!=null) {
return data.value;
} else {
print("prints - database.dart : data.value of user is empty/null");
return null;
}
},onError: (e){
print("prints - database.dart " + e.toString());
return null;
});
return null;
}
getDatabaseTransactions(String cUid) {
transactionsRef.orderByChild("transactions").once().then((DataSnapshot data){
if(data.value!=null) {
return data.value;
} else {
print("prints - database.dart : data.value of user is empty/null");
return null;
}
},onError: (e){
print("prints - database.dart " + e.toString());
return null;
});
return null;
}
getDatabaseTransaction(String cUid) {
transactionsRef.orderByChild(cUid).limitToFirst(1).once().then((DataSnapshot data){
if(data.value!=null) {
return data.value;
} else {
print("prints - database.dart : data.value of user is empty/null");
return null;
}
},onError: (e){
print("prints - database.dart " + e.toString());
return null;
});
return null;
}
}
For me, the problem was that I had 2 classes, now within both classes, I instantiated each other class.
Here is an example:
class Firestore{
final auth = Auth();
}
class Auth{
final fireStore = Firestore();
}
As you can see each class is calling the other class, that what caused the StackOverflow
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With