-
Notifications
You must be signed in to change notification settings - Fork 20
2. Construction and Connection
Ali Nasrabadi edited this page Jan 13, 2025
·
2 revisions
In order to work with Poolakey, You need to use connect
function and pass your RSA_KEY
.
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";
});
}
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.