postgres 1.0.2

  • Installing
  • Versions
  • 88


Build Status codecov

A library for connecting to and querying PostgreSQL databases.

This driver uses the more efficient and secure extended query format of the PostgreSQL protocol.


Create PostgreSQLConnections and open them:

var connection = new PostgreSQLConnection("localhost", 5432, "dart_test", username: "dart", password: "dart");

Execute queries with query:

List<List<dynamic>> results = await connection.query("SELECT a, b FROM table WHERE a = @aValue", substitutionValues: {
    "aValue" : 3

for (final row in results) {
  var a = row[0];
  var b = row[1];


Return rows as maps containing table and column names:

List<Map<String, Map<String, dynamic>>> results = await connection.mappedResultsQuery(

for (final row in results) {
  var tID = row["t"]["id"];
  var tName = row["t"]["name"];
  var uName = row["u"]["name"];

Execute queries in a transaction:

await connection.transaction((ctx) async {
    var result = await ctx.query("SELECT id FROM table");
    await ctx.query("INSERT INTO table (id) VALUES (@a:int4)", {
        "a" : result.last[0] + 1

See the API documentation:

Features and bugs

Please file feature requests and bugs at the issue tracker.



  • Add connection queue size


  • Prevent the table name resolution of OIDs <= 0.


  • Adds support for Dart 2


  • Add full support for UUID columns.


  • Preserve error stacktrace on various query or transaction errors.
  • Read support for BYTEA columns.


  • Adds Connection.mappedResultsQuery to return query results as a Map with keys for table and column names.


  • Adds Connection.notifications to listen for NOTIFY events (thanks @andrewst)
  • Adds better error reporting.
  • Adds support for JSONB columns.
  • Fixes issue when encoding UTF16 characters (thanks @andrewst)


  • Allow connect via SSL.


  • Fixed issue with buffer length


  • Fixed issue with UTF8 encoding


  • Bump for documentation


  • Added transactions: PostgreSQLConnection.transaction and PostgreSQLConnection.cancelTransaction.


  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  postgres: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:postgres/postgres.dart';
Version Uploaded Documentation Archive
1.0.2 Oct 9, 2018 Go to the documentation of postgres 1.0.2 Download postgres 1.0.2 archive
1.0.1 Oct 2, 2018 Go to the documentation of postgres 1.0.1 Download postgres 1.0.1 archive
1.0.0 Aug 6, 2018 Go to the documentation of postgres 1.0.0 Download postgres 1.0.0 archive
0.9.9 Apr 6, 2018 Go to the documentation of postgres 0.9.9 Download postgres 0.9.9 archive
0.9.8 Mar 28, 2018 Go to the documentation of postgres 0.9.8 Download postgres 0.9.8 archive
0.9.7 Mar 19, 2018 Go to the documentation of postgres 0.9.7 Download postgres 0.9.7 archive
0.9.6 Oct 5, 2017 Go to the documentation of postgres 0.9.6 Download postgres 0.9.6 archive
0.9.5 Mar 15, 2017 Go to the documentation of postgres 0.9.5 Download postgres 0.9.5 archive
0.9.4+1 Dec 13, 2016 Go to the documentation of postgres 0.9.4+1 Download postgres 0.9.4+1 archive
0.9.4 Dec 6, 2016 Go to the documentation of postgres 0.9.4 Download postgres 0.9.4 archive

All 15 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, other

Primary library: package:postgres/postgres.dart with components: io.

Health suggestions

Fix lib/src/connection.dart. (-0.50 points)

Analysis of lib/src/connection.dart reported 1 hint:

line 96 col 7: The value of the field '_secretKey' isn't used.

Format lib/src/binary_codec.dart.

Run dartfmt to format lib/src/binary_codec.dart.

Format lib/src/connection_fsm.dart.

Run dartfmt to format lib/src/connection_fsm.dart.

Fix additional 10 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/exceptions.dart (Run dartfmt to format lib/src/exceptions.dart.)
  • lib/src/execution_context.dart (Run dartfmt to format lib/src/execution_context.dart.)
  • lib/src/query.dart (Run dartfmt to format lib/src/query.dart.)
  • lib/src/query_cache.dart (Run dartfmt to format lib/src/query_cache.dart.)
  • lib/src/query_queue.dart (Run dartfmt to format lib/src/query_queue.dart.)
  • lib/src/server_messages.dart (Run dartfmt to format lib/src/server_messages.dart.)
  • lib/src/substituter.dart (Run dartfmt to format lib/src/substituter.dart.)
  • lib/src/text_codec.dart (Run dartfmt to format lib/src/text_codec.dart.)
  • lib/src/transaction_proxy.dart (Run dartfmt to format lib/src/transaction_proxy.dart.)
  • lib/src/types.dart (Run dartfmt to format lib/src/types.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use postgres.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
crypto ^2.0.0 2.0.6
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.0.2
typed_data 1.1.6
Dev dependencies
coverage any
test ^1.3.0