profilePage.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. Widget build(BuildContext context) {
  15. final arguments = (ModalRoute.of(context)?.settings.arguments ??
  16. <String, dynamic>{}) as Map;
  17. print('******' + arguments['id']);
  18. //getting info of the user one by one
  19. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  20. .get().then((DocumentSnapshot) {
  21. name = DocumentSnapshot.get('name').toString();
  22. });
  23. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  24. .get().then((DocumentSnapshot) {
  25. surname = DocumentSnapshot.get('surname').toString();
  26. });
  27. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  28. .get().then((DocumentSnapshot) {
  29. birth_date = DocumentSnapshot.get('birth_date').toString();
  30. });
  31. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  32. .get().then((DocumentSnapshot) {
  33. mail = DocumentSnapshot.get('mail').toString();
  34. });
  35. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  36. .get().then((DocumentSnapshot) {
  37. shared_id = DocumentSnapshot.get('shared_id').toString();
  38. });
  39. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  40. .get().then((DocumentSnapshot) {
  41. phone_number = DocumentSnapshot.get('phone_number').toString();
  42. });
  43. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  44. .get().then((DocumentSnapshot) {
  45. anonymous = DocumentSnapshot.get('anonymous').toString();
  46. });
  47. FirebaseFirestore.instance.collection('profileInfo').doc(arguments['id'])
  48. .get().then((DocumentSnapshot) {
  49. address = DocumentSnapshot.get('address').toString();
  50. });
  51. return Scaffold(
  52. appBar: AppBar(title: const Text('Profile Page')),
  53. body: Center(
  54. child: SizedBox(
  55. width: 300,
  56. child: Column(
  57. children: [
  58. const SizedBox(height: 30),
  59. Text(
  60. 'Personal Information',
  61. style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
  62. ),
  63. const SizedBox(height: 30),
  64. Image.asset(
  65. 'assets/user.png',
  66. width: 150,
  67. ),
  68. const SizedBox(height: 30),
  69. Text('Name: ' + name + ' ' + surname),
  70. const SizedBox(height: 10),
  71. Text('Birth Date: ' + birth_date),
  72. const SizedBox(height: 10),
  73. Text('Username: ' + shared_id),
  74. const SizedBox(height: 10),
  75. Text('Mail: ' + mail),
  76. const SizedBox(height: 10),
  77. Text('Phone: ' + phone_number),
  78. const SizedBox(height: 10),
  79. Text('Address: ' + address),
  80. const SizedBox(height: 10),
  81. Text('Anonymous: ' + anonymous),
  82. const SizedBox(height: 30),
  83. ElevatedButton(
  84. onPressed: () {
  85. setState(() {});
  86. },
  87. child: const Text('Refresh'),
  88. ),
  89. ],
  90. ),
  91. ),
  92. ),
  93. );
  94. }
  95. }