Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previous results of getLocation doesnt execute when using the future. #977

Open
IzacPS opened this issue Aug 6, 2024 · 0 comments
Open

Comments

@IzacPS
Copy link

IzacPS commented Aug 6, 2024

Describe the bug
When I use the method getLocation() waiting for the future result, only the last one is returned. All the previous ones stops executing. An example would be something like the code below:
All the permissions where requested and granted before hand in this case.

    Location loc = Location();

    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
//this builder doesnt execute
          FutureBuilder(
              future: loc.getLocation(),
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  return Text(snapshot.data!.toString());
                }
                return Text("loading");
              }),
//this executes
          FutureBuilder(
              future: loc.getLocation(),
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  return Text(snapshot.data!.toString());
                }
                return Text("loading");
              }),
        ],
      ),
    );

Only the second future builder in this case will finish its execution. If I add one more Futurebuilder the same thing happens and only the last one will execute.

Expected behavior
Just wondering if this is the right behavior. One would expect to get the result on all cases.

Tested on:

  • Android, API Level 34 on simulator and real device

Other plugins:

Additional logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant