I'am trying to show the datas from my firestore database into my user profile I made a separate class to get the datas. Now I'm having trouble on how to display it or call the class so that I can show the specific datas in the UI of my User Profile Screen. here is my database management class
class DatabaseManagement {
final FirebaseFirestore _database = FirebaseFirestore.instance;
Future getVisitorDetails({required String uid}) async {
final CollectionReference userList =
_database.collection('userList');
try {
DocumentSnapshot ds = await userList.doc(uid).get();
String firstname = ds.get('firstName');
String lastname = ds.get('lastName');
String email = ds.get('email');
String? phoneNumber = ds.get('phoneNumber');
String address = ds.get('address');
return [firstname, lastname, email, phoneNumber, address];
} catch (e) {
print(e.toString());
return null;
}
}
Here is my Profile Screen where the datas should be displayed
class ProfileScreen extends StatefulWidget {
const ProfileScreen({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _ProfileScreenState();
class _ProfileScreenState extends State<ProfileScreen> {
String firstName,
String lastName,
String email,
String? phoneNumber,
String address,
String uid,
Container(
constraints: const BoxConstraints(
minWidth: 250,
maxWidth: 350,
),
child: Column(
children: [
detailsWidget(
icon: Icons.person,
field: 'Full Name',
value: name,
),
detailsWidget(
icon: Icons.email_rounded,
field: 'Email',
value: email,
),
detailsWidget(
icon: Icons.phone,
field: 'Phone Number',
value: phoneNumber,
), }