Minimal example
This shows the minimal possible example to integrate Flutter Nakama into your app.
Last updated
Was this helpful?
This shows the minimal possible example to integrate Flutter Nakama into your app.
Last updated
Was this helpful?
In this example we initialize the Nakama SDK, sign in as a static user and create a match where other user's can join later on.
After booting the app, initialize Nakama SDK with required parameters:
You can optionally provide httpPort
and grpcPort
if you want to customize them. Default values are same as .
Sign in with the user's credentials, for example with email & password:
Tip: there is no difference between sign in and sign up at Nakama. You can find out via
session.created
if the account has been created or it is a recurring sign in.
All realtime communication runs though a WebSocket connection. You need to initialize this once after authentication. Then you establish a connection until the user closed the app:
Don't forget to close after disposing the app widget:
The simplest thing is to create a match and join with another's account.
On another instance:
flutter_nakama provides a handy way to listen to realtime events sent from the Nakama server. For example you can listen on match data:
You can send match data from your client like so:
You are absolutely free on what and how sending match data. You are free to use JSON or protobuf while the latter might result in very good performance. But you can also just send free text.
You receive an instance of which contains userId
and accessToken
among others. You are now logged in.
Please refer to the docs on more detailed information on how the realtime data works and which fields are available to use.