currentUser.dart 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. Stream<int> place = AuthenticationServices.getPlace(user2);
  26. return Row(
  27. children: [
  28. SizedBox(
  29. height: 100,
  30. width: 55,
  31. ),
  32. SizedBox(
  33. height: 100,
  34. width: 50,
  35. child: StreamBuilder(
  36. stream: place,
  37. builder: (context, snapshot) {
  38. return Text("${snapshot.data}");
  39. },
  40. ),
  41. ),
  42. SizedBox(
  43. height: 100,
  44. width: 135,
  45. child: Text(user2.sharedId),
  46. ),
  47. SizedBox(
  48. height: 100,
  49. width: 60,
  50. child: Text(user2.name),
  51. ),
  52. // SizedBox(
  53. // height: 100,
  54. // width: 50,
  55. // child: Text("${user2[widget.name]}"),
  56. // ),
  57. ],
  58. );
  59. }
  60. return const Text('Something went wrong');
  61. },
  62. );
  63. }
  64. }