Flutter Plugin - Dio Integration

This guide describes how to integrate the DataDome Plugin for Flutter using the Dio client.

Pub GitHub license

DataDome Flutter - Dio Integration

DataDome Flutter Dio plugin is an flutter plugin to support DataDome protection using Dio http client. The plugin provides an interceptor that filters and validates all requests to ensure your app networking layer is protected with DataDome.

Displaying the captcha, managing the cookies and handling the event tracker are all managed by the plugin.

Install the plugin

To install the plugin, add the datadome_flutter_dio dependency to your pubspec.yaml file as shown in the following

  datadome_flutter_dio: ^1.0.5
    sdk: flutter

Note: Make sure your project does support Swift/Kotlin. If not, enable Swift/Kotlin for your Flutter project by executing the following command

flutter create -i swift -a kotlin


The DataDome Flutter Dio plugin provides an interceptor to be configured with your existing Dio instance. The plugin will intercept all requests performed by Dio, catch any signal from the DataDome remote protection module, display a captcha if relevent and then retry the failed requests.
This is all managed by the plugin.

Import the DataDome Interceptor

You can import the DataDome Interceptor class using the following statement

import 'package:datadome_flutter_dio/datadome_interceptor.dart';

Initialize the DataDome Interceptor

Make sure you create an instance of the DataDome interceptor by passing:

  • The DataDome client side key
  • The Dio client
  • The context to be used to display a captcha eventually

Once created, you can add the interceptor to Dio

var dio = Dio();
dio.interceptors.add(DataDomeInterceptor('YOUR_CLIENT_SIDE_KEY', dio, context));

Force a captcha display

To test and validate your integration, use a specific header to force the DataDome remote protection module to block the request and force the plugin to display the captcha. We use the User-Agent header with the value BLOCKUA to hint the remote module to block the request.
Please note that the captcha is displayed once and then the generated cookie is stored locally.

Here a sample code to perform a GET request while forcing a captcha display

var dio = Dio();
dio.interceptors.add(DataDomeInterceptor('YOUR_CLIENT_SIDE_KEY', dio, context));
try {
  var response = await dio.get(
                options: Options(headers: {'User-Agent': 'BLOCKUA'})
} catch (e) {

IMPORTANT Do not leave this header in production. This will lead all users to see a captcha at least once.