currentUser.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'Services/AuthService.dart';
  5. class CurrentUser extends StatefulWidget {
  6. const CurrentUser( {
  7. 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 dynamic user = _auth.getCurrentUser();
  15. @override
  16. Widget build(BuildContext context) {
  17. return FutureBuilder<dynamic>(
  18. future: user,
  19. builder: (context, snapshot) {
  20. if(snapshot.connectionState == ConnectionState.waiting){
  21. return const Text('Wait a moment');
  22. }
  23. else if(snapshot.connectionState == ConnectionState.done) {
  24. dynamic user2 = snapshot.data.docs[0];
  25. // DatabaseManager manager = DatabaseManager(widget.name);
  26. Stream<int> place = _auth.getPlace(user2);
  27. return Row(
  28. children: [
  29. SizedBox(
  30. height: 100,
  31. width: 55,
  32. ),
  33. SizedBox(
  34. height: 100,
  35. width: 50,
  36. child: StreamBuilder(
  37. stream: place,
  38. builder: (context, snapshot){
  39. return Text(
  40. "${snapshot.data}");
  41. },
  42. ),
  43. ),
  44. SizedBox(
  45. height: 100,
  46. width: 135,
  47. child: Text(user2["shared_id"]),
  48. ),
  49. SizedBox(
  50. height: 100,
  51. width: 60,
  52. child: Text(user2["name"]),
  53. ),
  54. SizedBox(
  55. height: 100,
  56. width: 50,
  57. child: Text("${user2[widget.name]}"),
  58. ),
  59. ],
  60. );
  61. }
  62. return const Text('Something went wrong');
  63. },
  64. );
  65. }
  66. }