import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; class ProfilePage extends StatefulWidget { const ProfilePage({Key? key, required this.title}) : super(key: key); final String title; @override //_RegisterScreen createState() => _RegisterScreen(); State createState() => _ProfilePage(); } class _ProfilePage extends State { String name = '', surname = '', birth_date = '', mail = '', shared_id = '', phone_number = '', anonymous = '', address = ''; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { final arguments = (ModalRoute.of(context)?.settings.arguments ?? {}) as Map; FirebaseFirestore.instance.collection('Users').doc(arguments['id']) .get().then((DocumentSnapshot) { name = DocumentSnapshot.get('name').toString(); surname = DocumentSnapshot.get('surname').toString(); birth_date = DocumentSnapshot.get('birth_date').toString(); mail = DocumentSnapshot.get('mail').toString(); shared_id = DocumentSnapshot.get('shared_id').toString(); phone_number = DocumentSnapshot.get('phone_number').toString(); anonymous = DocumentSnapshot.get('anonymous').toString(); address = DocumentSnapshot.get('address').toString(); }); return Scaffold( appBar: AppBar(title: const Text('Profile Page')), body: Center( child: SizedBox( width: 300, child: Column( children: [ const SizedBox(height: 30), Text( 'Personal Information', style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox(height: 30), Image.asset( 'assets/user.png', width: 150, ), const SizedBox(height: 30), Text('Name: ' + name + ' ' + surname), const SizedBox(height: 10), Text('Birth Date: ' + birth_date), const SizedBox(height: 10), Text('Username: ' + shared_id), const SizedBox(height: 10), Text('Mail: ' + mail), const SizedBox(height: 10), Text('Phone: ' + phone_number), const SizedBox(height: 10), Text('Address: ' + address), const SizedBox(height: 10), Text('Anonymous: ' + anonymous), const SizedBox(height: 30), ElevatedButton( onPressed: () { setState(() {}); }, child: const Text('Refresh'), ), ], ), ), ), ); } }