currentUser.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:physigo/Services/logged_in_user.dart';
  5. import 'Services/AuthService.dart';
  6. class CurrentUser extends StatefulWidget {
  7. const CurrentUser({required this.name, Key? key}) : super(key: key);
  8. final String name;
  9. @override
  10. State<CurrentUser> createState() => _CurrentUserState();
  11. }
  12. class _CurrentUserState extends State<CurrentUser> {
  13. final AuthenticationServices _auth = AuthenticationServices();
  14. late Future<LoggedInUser?> user = AuthenticationServices.getCurrentUser();
  15. @override
  16. Widget build(BuildContext context) {
  17. return FutureBuilder<LoggedInUser?>(
  18. future: user,
  19. builder: (context, snapshot) {
  20. if (snapshot.connectionState == ConnectionState.waiting) {
  21. return const Text('Wait a moment');
  22. } else if (snapshot.connectionState == ConnectionState.done) {
  23. LoggedInUser user2 = snapshot.data!;
  24. // DatabaseManager manager = DatabaseManager(widget.name);
  25. return Row(
  26. children: [
  27. SizedBox(
  28. height: 100,
  29. width: 55,
  30. ),
  31. SizedBox(
  32. height: 100,
  33. width: 50,
  34. child: FutureBuilder(
  35. future: AuthenticationServices.getPlace(),
  36. builder: (context, snapshot) {
  37. return Text("${snapshot.data}");
  38. },
  39. ),
  40. ),
  41. SizedBox(
  42. height: 100,
  43. width: 135,
  44. child: Text(user2.sharedId),
  45. ),
  46. SizedBox(
  47. height: 100,
  48. width: 60,
  49. child: Text(user2.name),
  50. ),
  51. // SizedBox(
  52. // height: 100,
  53. // width: 50,
  54. // child: Text("${user2[widget.name]}"),
  55. // ),
  56. ],
  57. );
  58. }
  59. return const Text('Something went wrong');
  60. },
  61. );
  62. }
  63. }