data_dome_plugin 1.0.2

Flutter Android iOS

Plugin for DataDome.

DataDome plugin for Flutter #

Pub GitHub license

Flutter has it's own network implementation, but this plugin uses URLSession and OkHttp for iOS and Android, respectively.

Note

If your project doesn't support swift/kotlin then you can check here.

iOS #

  1. Add the key DataDomeKey with your DataDome key string value to ../ios/Runner/Info.plist.
  2. Add the key DataDomeProxyEnabled with the boolean value NO to ../ios/Runner/Info.plist.

Forcing captcha display on iOS.

Android #

The method call has a key parameter that is used to pass the DataDome key.

Forcing captcha display on Android but could not get it to work.

Usage #

    try {
      final headers = {
        'Content-type': 'application/json',
        'Accept': 'application/json',
      };
      //TODO: fill in url, DataDome key for android
      final key = '';
      final url = '';
      final json = {
        "any": "body",
        "some": 1,
        "is": true,
      };
      final body = Uint8List.fromList(utf8.encode(jsonEncode(json)));
      final result = await DataDomePlugin.httpCall(
        HttpMethod.post,
        url,
        headers,
        body,
        key,
      );
      final response = _makeResponse(result);
      print(response.statusCode.toString());
    } on PlatformException {
      print('Failed HTTP call');
    }
.
.
.
  http.Response _makeResponse(Map<String, dynamic> resp) {
    final int code = resp['code'] ?? 500;
    final Uint8List data = resp['data'] ?? Uint8List(0);
    return http.Response.bytes(
      data.toList(),
      code,
      headers: {'content-type': 'application/json; charset=utf-8'},
    );
  }