Installation & Setup

Prepare Nakama Dev environment

I suggest starting with Docker for your local dev environment. You find a tutorial in the official docs how to install Nakama: https://heroiclabs.com/docs/install-docker-quickstart/

Install Flutter Nakama SDK

I assume you have basic knowledge about how to use flutter and dart. And you already have an existing project.

This package is available on pub.dev. Start over with adding flutter_nakama as a dependency to your project's pubspec.yaml:

name: your_game
dependencies:
    flutter:
        sdk: flutter
    flutter_nakama: ^0.1.0

This Package is available as open source. Please share your feedback by creating an issue on GitHub.

Initialize base client

We handle all the magic hidden behind the package regarding cross platform support. While the communication with Nakama runs with a very high performance via gRPC but gRPC is not supported in web without using a proxy, it automatically uses HTTP(S) on web.

Initialize the SDK in an early point of your app with your host and serverKey. The serverKey is used if you are not yet authenticated as a user.

The default value of serverKey is defaultKey! You can change this in Nakama's config.

final client = getNakamaClient(
  host: '127.0.0.1',
  ssl: false,
  serverKey: 'defaultkey',
  grpcPort: 7349, // optional
  httpPort: 7350, // optional
);

Singleton

You can obtain the client's singleton instance any time later via

final client = getNakamaClient();

But be sure to call it once with the required parameters host, ssl and serverKey.

Last updated