flutter firebase showing data

0 votes

Users make a post, say ADS post. Different users interact with the post by sending requests. I'm using different emulators to check this.

When I use an emulator for user A to access an ADS post and sends a requests, the device(emulator A) displays the ADS posts to which the user A has sent the request to.

However, when I use a different divice(emulator B) for user B to access an ADS post, (even when the post is not the same as the post accessed by user A), the emulator displays the ADS post to which the user has send the request, but then the emulator A no longer displays the ADS posts to which user A has sent the request.

I tried a lot of emulators and the same thing is happening. Any solution?

My code for accessing the requests of a user.

QueryDocumentSnapshot<Map<String, dynamic>>? selectedRide;
  DateTime dateTime = DateTime.now();
  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    // final screenHeight = MediaQuery.of(context).size.height;
    return StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
      stream:
          FirebaseFirestore.instance.collectionGroup('Requests').snapshots(),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return ListView.builder(
              scrollDirection: Axis.vertical,
              itemCount: snapshot.data!.docs.length,
              itemBuilder: (context, index) {
                final request = snapshot.data!;
                String currentID = request.docs[index].get('UID');
                if (currentID == FirebaseAuth.instance.currentUser!.uid) {
                  return Card(
                    child: ListTile(
                      onTap: () {
                        Navigator.push(
                            context,
                            MaterialPageRoute(
                                builder: (context) => MyRidesPageScreen(
                                      selectedRide: selectedRide,
                                    )));
                        setState(() {
                          selectedRide = snapshot.data!.docs[index];
                        });
                      },
                      title: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          SizedBox(
                            width: screenWidth * 0.15,
                            child: Text(
                              snapshot.data!.docs[index].get('Departure date'),
                              style: const TextStyle(color: Colors.blue),
                            ),
                          ),
                          SizedBox(
                            width: screenWidth * 0.2,
                            child: Text(snapshot.data!.docs[index]
                                .get('Departure city')),
                          ),
                          SizedBox(
                            width: screenWidth * 0.1,
                            child: const Text('-'),
                          ),
                          SizedBox(
                            width: screenWidth * 0.2,
                            child: Text(
                                snapshot.data!.docs[index].get('Arrival city')),
                          ),
                          SizedBox(
                            width: screenWidth * 0.15,
                            child: Text(
                              snapshot.data!.docs[index].get('Departure time'),
                              style: const TextStyle(color: Colors.blue),
                            ),
                          ),
                        ],
                      ),
                    ),
                  );
                }
                return null;
              });
        }
        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Center(child: CircularProgressIndicator());
        }
        if (!snapshot.hasData) {
          return const Center(
            child: SizedBox(
              child: Text('You have not made any requests yet'),
            ),
          );
        }
        return const Center(child: CircularProgressIndicator());
      },
    );
  }

Apr 4, 2023 in Flutter by Ashwini
• 5,430 points
571 views

1 answer to this question.

0 votes

It seems that when using different emulators for different users to access an ADS post and send a request, the emulator of the first user no longer displays the ADS post to which they have sent the request. It is unclear what the specific solution is, but the provided code appears to be for displaying the requests of a user, rather than for resolving the issue.

answered Apr 4, 2023 by vishalini

Related Questions In Flutter

0 votes
1 answer

How to log data to the Flutter console?

To log data to the Flutter console ...READ MORE

answered Mar 27, 2023 in Flutter by anonymous
6,224 views
0 votes
1 answer

How to convert json data into array in Flutter?

To convert the JSON data into an ...READ MORE

answered Mar 31, 2023 in Flutter by seena
9,880 views
0 votes
1 answer

Linking 3 Flutter Projects in One Flutter Project

Yes, it is possible to combine multiple ...READ MORE

answered Mar 20, 2023 in Flutter by vinayak
364 views
0 votes
1 answer

Flutter Projects & Android X Migration Issues

Migrating to AndroidX can be a frustrating ...READ MORE

answered Mar 20, 2023 in Flutter by Tej
281 views
0 votes
1 answer
0 votes
1 answer

What are some advantages of Flutter?

Hi@akhtar, Nowadays Flutter is taking the market. It ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,440 points
585 views
0 votes
1 answer

'git rev-parse HEAD' is not recognized as an internal or external command

Hi@akhtar, I also faced the same problem. You ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,440 points
3,550 views
+1 vote
3 answers

Flutter plugin not installed; this adds Flutter specific functionality.

Here Is All Possible Solution Added Flutter ...READ MORE

answered Dec 16, 2020 in Others by Blogging
• 140 points
20,598 views
0 votes
1 answer
0 votes
1 answer

flutter app not running on ios simulator after adding firebase notification

The error message you provided seems to ...READ MORE

answered Apr 10, 2023 in Flutter by vishalini
4,679 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP