Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8935177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:56:21+00:00 2026-06-15T09:56:21+00:00

Future readData() { var completer = new Completer(); print(querying); pool.query(‘select p.id, p.name, p.age, t.name,

  • 0
Future readData() {
    var completer = new Completer();
    print("querying");
    pool.query('select p.id, p.name, p.age, t.name, t.species '
        'from people p '
        'left join pets t on t.owner_id = p.id').then((result) {
      print("got results");
      for (var row in result) {
        if (row[3] == null) {
          print("ID: ${row[0]}, Name: ${row[1]}, Age: ${row[2]}, No Pets");
        } else {
          print("ID: ${row[0]}, Name: ${row[1]}, Age: ${row[2]}, Pet Name: ${row[3]},     Pet Species ${row[4]}");
        }
      }
      completer.complete(null);
    });
    return completer.future;
  }

The above is an example code taken from github SQLJocky Connector

I would like someone to explain me if possible why is the function which has a completer object created outside the pool.query is then calling a function completer.complete(null).

In short I am not able to understand the part after print executes.

Note:Kindly if possible I would also like to know how is future and Completer used for practical purpose both for DB and non DB operations.

I have explored the following links:
Google groups discussion on Future and Completer

and the api reference documentation which is as given below
Completer api reference and Future api Reference

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:56:22+00:00Added an answer on June 15, 2026 at 9:56 am

    The Future object that is returned by that method is, in a sense, connected to that completer object, which will complete at some point “in the future”. The .complete() method is called on the Completer, which signals the future that it is complete. Here’s a more simplified example:

    Future<String> someFutureResult(){
       final c = new Completer();
       // complete will be called in 3 seconds by the timer.
       new Timer(3000, (_) => c.complete("you should see me second"));
       return c.future;
    }
    
    main(){
       someFutureResult().then((String result) => print('$result'));
       print("you should see me first");
    }
    

    Here’s a link to a blog post which details other scenarios where futures are helpful

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the near future, my organisation will have to change both the machine name
from future import division To perform a division in which I need some percision.
Update for future readers: When .NET 4 comes out, LazyInit<T> from the CTP will
In the very near future I'll be migrating some web applications from VS2003 projects
In the near future I'll need to start reading an Access 2003 database from
In near future I'll need to start working on a new project that consist
from __future__ import division import math def main(): the_discriminant = discrim(1,0,-4) print the_discriminant the_rest(discrim,b,a)
Everytime FutureContent.future is called why will a new MyFuture class not be created and
This class hangs at Future.get() method after executing ExecutorService.shutdownNow() called. I don't know what
Are there any future plans to replace selenium and watir with mechanize + johnson?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.