getProfile static method
It finds the user in the 'users' reference from the
Firebase Realtime Database and returns its information
as a list. In order for this function to work successfully,
the user must be registered with register.
Implementation
static Future<List> getProfile() async {
if (JeaFire.isSignedIn()) {
FirebaseAuth auth = FirebaseAuth.instance;
String getUid = auth.currentUser!.uid;
DatabaseReference ref = FirebaseDatabase.instance.ref("users");
DataSnapshot snapshot = await ref.get();
Map mapX = snapshot.value as Map;
String user = "";
List mapList = mapX.keys.toList();
for (var i = 0; i < mapList.length; i++) {
if (mapList[i].toString().contains(getUid)) {
user = mapList[i];
}
}
DatabaseReference refer = FirebaseDatabase.instance.ref("users/$user");
DataSnapshot snapval = await refer.get();
return JeaFire.decode(snapval.value.toString());
} else {
return [];
}
}