Skip to content

2. Construction and Connection

Ali Nasrabadi edited this page Aug 23, 2025 · 3 revisions

In order to work with Poolakey, You need to use connect function and pass your RSA_KEY.

Version 2.2.0+1.0.0

    try {
      await FlutterPoolakey.connect(
        rsaKey,
        onSucceed: () {
          connected = true;
          _updateState("Service: Connected");
        },
        onFailed: () {
          connected = false;
          _updateState("Service: Not Connected");
        },
        onDisconnected: () {
          connected = false;
          _updateState("Service: Not Connected");
        },
      );
    } on Exception catch (e) {
      showSnackBar(e.toString());
      _updateState("Service: Failed to Connect");
    }

The first parameter is RSA_KEY is the RSA key which you can find in your (pishkhan panel)[https://pishkhan.cafebazaar.ir]. You can also disable the local security check (only if you are using Bazaar's REST API) by passing null in RSA_KEY.

You should listen to onDisconnected callback and call FlutterPoolakey.connect to reconnect again.

This function may return an error, you should handle the error and check the stacktrace to resolve it.

Version 2.2.0 (DEPRECATED)

 try {
      bool connected = await FlutterPoolakey.connect(
        RSA_KEY,
        onDisconnected: () => showSnackBar("Poolakey disconnected!"),
      );
    } on Exception catch (e) {
      showSnackBar(e.toString());
      setState(() {
        status = "Service: Failed to Connect";
      });
    }

Clone this wiki locally