Tutorial: Build chat apps with PubNub using Flutter
This tutorial shows you how to build a scalable chat app with PubNub using Flutter.
Build a Chat App with the Flutter Chat SDK
This tutorial will walk you through developing a basic chat application in Flutter using PubNub Dart SDK.
The source code for this application can be found on Github at https://github.com/PubNubDevelopers/GettingStarted-Flutter-SDK-Tutorial
Prerequisites
Before running this application, be sure you have the following installed:
Any Flutter dependencies. For example, to target Android you will need the Android toolchain installed. Run “flutter doctor” to make sure you have everything you want installed correctly.
Download Source Application
In a terminal, navigate to an empty folder. Enter the following command to clone the repository:
git clone https://github.com/PubNubDevelopers/GettingStarted-Flutter-SDK-Tutorial.git
And navigate to the application folder:
cd GettingStarted-Flutter-SDK-Tutorial
cd flutter_sdk_tutorial
Important: Install the flutter packages that this app needs
flutter packages get
The main git branch contains the completed version of this tutorial. If you would like to follow along, please checkout the following branch:
git checkout tutorial_step_0
Create keys
Demo keys
You're ready to go!
We’ve assigned demo keys which are set up to support the features of this tutorial app. These will be active for 72 hours but you can sign up for a free account at the end of the tutorial to create your own permanent keys.
The demo keys have the following functionality activated ready for your application:
Presence
Message Persistence You will be able to see user’s message history and meta data.
Stream Controller You will be able to receive messages against a group of channels, or post one message to multiple channels.
App Context This allows you to manage the metadata of your users and channels.
My own keys
To use your own keys, create a free account and a keyset with Presence, Message Persistence, Stream Controller, and App Context on.
You can create the keyset with the Admin API, PubNub's REST API for account management. An Account Owner or Account Admin creates a Service Integration and its API key in the Admin Portal under Organization Settings → API Management. Give it read & write access to apps and keysets, plus read access to secret keys, which keyset creation requires. With that key, create an app, then create a keyset in it and pass the keyset's configuration in the same request. The response includes the publish and subscribe keys. See the Admin API documentation for the requests and keyset settings.
Build and run
Congratulations - what's next?
Chat SDK Documentation
Chat OverviewDart SDK DocsChat Developer PathLive Tour
Start the live coding tourExplore other Sample apps
Flutter reference app written by our engineering teamDeveloping to a tight deadline? Explore Chat Components
Chat Components IntroductionReady to get beyond Proof of Concept?
Schedule a 15 minute chat with one of our experts to get your project moving
Talk to an ExpertTake it to production on your own keys
Create a free PubNub account to get permanent keys for this app.