profilePage.dart 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import 'package:cloud_firestore/cloud_firestore.dart';
  2. import 'package:flutter/material.dart';
  3. class ProfilePage extends StatefulWidget {
  4. const ProfilePage({Key? key, required this.title}) : super(key: key);
  5. final String title;
  6. @override
  7. //_RegisterScreen createState() => _RegisterScreen();
  8. State<ProfilePage> createState() => _ProfilePage();
  9. }
  10. class _ProfilePage extends State<ProfilePage> {
  11. String name = '', surname = '', birth_date = '', mail = '', shared_id = '',
  12. phone_number = '', anonymous = '', address = '';
  13. @override
  14. void initState() {
  15. super.initState();
  16. }
  17. @override
  18. Widget build(BuildContext context) {
  19. final arguments = (ModalRoute.of(context)?.settings.arguments ??
  20. <String, dynamic>{}) as Map;
  21. FirebaseFirestore.instance.collection('Users').doc(arguments['id'])
  22. .get().then((DocumentSnapshot) {
  23. name = DocumentSnapshot.get('name').toString();
  24. surname = DocumentSnapshot.get('surname').toString();
  25. birth_date = DocumentSnapshot.get('birth_date').toString();
  26. mail = DocumentSnapshot.get('mail').toString();
  27. shared_id = DocumentSnapshot.get('shared_id').toString();
  28. phone_number = DocumentSnapshot.get('phone_number').toString();
  29. anonymous = DocumentSnapshot.get('anonymous').toString();
  30. address = DocumentSnapshot.get('address').toString();
  31. });
  32. return Scaffold(
  33. appBar: AppBar(title: const Text('Profile Page')),
  34. body: Center(
  35. child: SizedBox(
  36. width: 300,
  37. child: Column(
  38. children: [
  39. const SizedBox(height: 30),
  40. Text(
  41. 'Personal Information',
  42. style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
  43. ),
  44. const SizedBox(height: 30),
  45. Image.asset(
  46. 'assets/user.png',
  47. width: 150,
  48. ),
  49. const SizedBox(height: 30),
  50. Text('Name: ' + name + ' ' + surname),
  51. const SizedBox(height: 10),
  52. Text('Birth Date: ' + birth_date),
  53. const SizedBox(height: 10),
  54. Text('Username: ' + shared_id),
  55. const SizedBox(height: 10),
  56. Text('Mail: ' + mail),
  57. const SizedBox(height: 10),
  58. Text('Phone: ' + phone_number),
  59. const SizedBox(height: 10),
  60. Text('Address: ' + address),
  61. const SizedBox(height: 10),
  62. Text('Anonymous: ' + anonymous),
  63. const SizedBox(height: 30),
  64. ElevatedButton(
  65. onPressed: () {
  66. setState(() {});
  67. },
  68. child: const Text('Refresh'),
  69. ),
  70. ],
  71. ),
  72. ),
  73. ),
  74. );
  75. }
  76. }