For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

Flutter Data API

Connect to chat data from Flutter-based environments.

View as Markdown

The Flutter Data API lets you connect to TalkJS as a user and read, subscribe to, and update chat data from Flutter-based environments. It's available through the talkjs_core_flutter package on pub.dev.

The Data API is primarily intended for client environments such as mobile apps, because it connects as a single specific user.

If you need server-side access to all conversations or users, use the REST API instead.

Platform support

The Flutter Data API supports Android and iOS.

Requirements

To use the Flutter Data API, your project needs to have the following:

  • Dart 3.12.0+
  • Flutter 3.44.0+
  • For Android apps: Android API 24+
  • For iOS apps: iOS 15+

Installation

To add the TalkJS Core Flutter package to your project, run:

1flutter pub add talkjs_core_flutter

Create a TalkJS session

To connect as a user, create a TalkJS session using getTalkSession:

1import 'package:talkjs_core_flutter/talkjs_core_flutter.dart';
2
3final session = await getTalkSession(
4 appId: '<APP_ID>', // Replace with your own app ID
5 userId: '<USER_ID>', // Replace with a user ID
6);

Replace:

  • <APP_ID> with your TalkJS app ID. You can find your app ID on the Settings page of your TalkJS dashboard.
  • <USER_ID> with the ID of the user you want to connect as.

Once connected, the session allows you to retrieve conversations, send messages, and subscribe to real-time updates.

Android permissions

To use TalkJS in your app, it must have permission to access the internet. In your AndroidManifest.xml file, make sure the following line is present:

1<uses-permission android:name="android.permission.INTERNET" />

This is required for TalkJS to connect to the TalkJS servers.

Troubleshooting

This section provides troubleshooting instructions for issues that you may come across.

iOS build failure

When building for iOS (flutter build ios) you could encounter the error Value of type 'TalkSession' has no member 'uploadFile'. This is because Flutter tried to compile for the x86_64 target, which is not supported.

To only check if the app compiles, run flutter build ios --no-codesign; running your app with flutter run works fine.