Requirements
- Dart >= 3.9.2
- Flutter >= 3.35.7
Installation
Add the following dependency to yourpubspec.yaml file:
Localization
Mesh SDK uses theflutter_localizations package for localization. For it to work, you need to add MeshLocalizations.localizationsDelegates to your MaterialApp.localizationsDelegates:
Get Link Token
Link token should be obtained from the POST/api/v1/linktoken endpoint. API reference for this request is available here. The request must be performed from the server side because it requires the client’s secret. You will get the response in the following format:
Launch Link
Configuration
Here’s what you can configure in theMeshConfiguration:
| Parameter | Type | Required | Description |
|---|---|---|---|
linkToken | String | Yes | Link token obtained from the backend. |
language | String | No | Language, defaults to “en”. |
isDomainWhitelistEnabled | bool | No | If domain should be checked against our whitelist. Defaults to true. |
integrationAccessTokens | List<IntegrationAccessToken> | No | List of cached IntegrationAccessTokens that you can pass, so users don’t need to connect every time. |
onError | ValueChanged<MeshErrorType>? | No | Error callback with a MeshErrorType that describes the error. |
onSuccess | ValueChanged<MeshSuccess>? | No | Success callback with SuccessPayload that contains more info about the transfer or integration. |
onEvent | ValueChanged<MeshEvent>? | No | Callback for when an event is triggered. |
onIntegrationConnected | ValueChanged<IntegrationConnectedEvent>? | No | Callback for when an integration is connected. Use this to store the access token. |
onTransferFinished | ValueChanged<TransferFinishedEvent>? | No | Callback for when a crypto transfer is executed. |
Callbacks
onIntegrationConnected
Called when a user successfully connects an integration. The callback receives an IntegrationConnectedEvent containing the access token that you should securely store for future use.
onTransferFinished
Called when a crypto transfer has been executed. The callback receives a TransferFinishedEvent containing details about the transfer status and transaction information.
onEvent
Called to provide details on the user’s progress while interacting with the Link UI. This can be used for analytics and understanding user behavior.
onExit
Called when a user exits the Link flow. The callback may receive an error type if the exit was due to an error.
Using Access Tokens
If the end user has an already connected integration, you can pass theintegrationAccessTokens to skip re-authentication:
Whitelist
By default, domain whitelisting is enabled. To disable the whitelist check, setisDomainWhitelistEnabled: false in the MeshConfiguration.