---
title: "Flutter SDKs for Firebase Data Connect"
description: "Flutter SDKs for Firebase Data Connect"
published: "2024-12-12"
last_updated: "2024-12-12"
authors:
  - "Maneesh Tewani (Software Engineer)"
categories:
  - "SQL Connect"
  - "Flutter"
  - "GraphQL"
  - "PostgreSQL"
canonical_url: "https://firebase.blog/posts/2024/12/dataconnect-flutter-sdks"
---

# Flutter SDKs for Firebase Data Connect

*Published December 12, 2024 by Maneesh Tewani (Software Engineer)*

---
> **Note:** Firebase Data Connect has been renamed to SQL Connect. Learn more in the [SQL Connect announcement](https://firebase.blog/posts/2026/04/whats-new-sql-connect).

With Firebase Data Connect's recent [public preview launch](https://firebase.blog/posts/2024/10/data-connect-public-preview), we're excited to announce the launch of one of the most requested features: [native Flutter SDKs for Data Connect](https://firebase.google.com/docs/data-connect/flutter-sdk)! In this post, we'll go over how to use them in your app.

### What is Firebase Data Connect?

At Google I/O, we [launched](https://firebase.blog/posts/2024/05/introducing-firebase-data-connect) Firebase Data Connect, a backend-as-a-service powered by a Cloud SQL Postgres database that's high performance, scalable, and secure. It utilizes [GraphQL](https://firebase.blog/posts/2024/10/dataconnect-graphql) to provide users a way to define your data and the relationships between them, as well as interactions with your data.

Our existing offering provided Android, iOS, and Web support, and now we're excited to announce a new set of SDKs for Flutter, written entirely in native Dart. With a new generated SDK, in a few lines of Flutter code, you get access to your Cloud SQL data with full type-safety included!

Instead of having to type out `parseJsonToMyMovie(myOrm().select('title, genre, description').from('movies'));`, all you have to do is call `MoviesConnector.instance.listMovies();` and you're good to go!

Can't wait to try it out? Install our [VSCode extension](https://marketplace.visualstudio.com/items?itemName=GoogleCloudTools.firebase-dataconnect-vscode) and follow the steps below, or take a look at the [documentation](https://firebase.google.com/docs/data-connect/flutter-sdk).

### Getting started

If you haven't already, add Firebase to your Flutter app by [following these steps](https://firebase.google.com/docs/flutter/setup).

To start generating the new Flutter SDK, add the following configuration to your `dataconnect/connector/connector.yaml` file:

**`dataconnect/connector/connector.yaml`**

```yaml
generate:
  dartSdk:
    outputDir: "./lib/generated"
    package: "movies"
```

The `outputDir` specifies where the generated SDKs should live, and the `package` defines the name of the new Dart package where the generated code will live.

Next, let's add some tables to our schema:

**`dataconnect/schema/schema.gql`**

```graphql
type Movie @table {
  # The below parameter values are generated
  # by default with @table, and can be edited
  # manually.
  #
  # implies directive '@col(name: "movie_id")',
  # generating a column name
  id: UUID! @default(expr: "uuidV4()")
  title: String!
  imageUrl: String!
  genre: String
}
```

Add a new query to our list of operations: 

**`dataconnect/connector/queries.gql`**

```graphql
# @auth() directives control who can call
# each operation.
# Anyone should be able to list all movies,
# so the auth level is set to PUBLIC
query ListMovies @auth(level: PUBLIC) {
  movies {
    id
    title
    imageUrl
    genre
  }
}
```

**Note: We use `PUBLIC` in the example below as this doesn't expose sensitive information. We recommend using stricter auth on restrictive operations.**

And add a new mutation to add a new movie into the list:

**`dataconnect/connector/mutations.gql`**

```graphql
mutation CreateMovie(
  $title: String!
  $genre: String!
  $imageUrl: String!
) @auth(level: USER) {
  movie_insert(
    data: {
      title: $title
      genre: $genre
      imageUrl: $imageUrl
    }
  )
}
```

Now let's call it! 

First, install the Data Connect core SDKs:

```bash
flutter pub add firebase_data_connect
```

Then, add the following to your `main.dart`:

**`lib/main.dart`**

```dart
...
import 'package:fdc_flutter_blog_post/generated/movies.dart';
...
// Add logic to log in a user
...
// Add a movie if one doesn't exist already
await MoviesConnector.instance
      .createMovie(
          title: "Quantum Paradox",
          genre: "sci--fi",
          imageUrl:
              "https://firebasestorage.googleapis.com/v0/b/fdc-web-quickstart.appspot.com/o/movie%2Fquantum_paradox.jpeg?alt=media&token=4142e2a1-bf43-43b5-b7cf-6616be3fd4e3")
      .execute();

// Call the ListMovies query we created earlier
MoviesConnector.instance.listMovies().execute().then((res) {
  setState(() {
    _movies = res.data.movies;
  });
});
```

Here's a sample app using that query:

![Movie Review app](https://firebasestorage.googleapis.com/v0/b/first-class-blog.appspot.com/o/posts%2Fflutter_sdks_fdc_1600x800.webp?alt=media&token=b14016a0-511a-44f7-8ca4-75cb28cc392b)

### Learn More!

To learn more about developing Flutter apps using Data Connect, visit our [documentation](https://firebase.google.com/docs/data-connect/flutter-sdk), and try out our quickstart by cloning our [GitHub repo](https://github.com/firebase/quickstart-flutter)!
