Flutter SDK

Pre Requisites

Zonka Feedback Flutter SDK requires an active Zonka Feedback account. To successfully run and test out the survey you would need to have an SDK token for the survey you want to implement. If you are already a user and have access to your SDK token you can directly jump to the Installation section. If not, read on and follow the following steps:

  • Create a new account on Zonka Feedback

  • Create a new survey with a choice of questions you would like to implement

  • Once your survey is created go to Distribute menu and click on the In-App tab

  • Enable the toggle to view the SDK token

  • Follow the below-mentioned steps to implement it in your app

Learn more about creating surveys on Zonka Feedback here

Minimum Requirements

Flutter SDK enables you to collect feedback from your Android App and is compatible with apps running on both mobile and tablets for iOS and Android operating systems.

Flutter

  • Flutter version 3.0.0 or higher.

Android

  • CompileSdk version 34 or higher.

  • Android Gradle Plugin version 8.1.0 or higher with a compatible Gradle version.

iOS

  • iOS 14 or higher.

Installation

To use this SDK, add zonkafeedback_sdk as a dependency in your pubspec.yaml file.

Initialize

Initialize the SDK in your application using init() method. Call this method only once, in the main component (e.g. lib/main.dart file).

import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    ZFSurvey().init(token: {{SDK_TOKEN}} ,zfRegion: '{{REGION}}',context: context);;
  }
}

For Regions use the following

  • US - for US Region

  • EU - for European Region

  • IN - for India Region

Setup

Create a ZFSurvey object to configure and start the survey for feedback in your function.

import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';

ZFSurvey().startSurvey();

Optional Parameters

Using sendDeviceDetails

You can set the value of sendDeviceDetails to true if you want to submit details of your device along with the Zonka Feedback survey response. This would send the details of the device such as OS, OS version, IP address, and type of device. When you implement SDK it's true by default.

import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';

ZFSurvey().sendDeviceDetails(true);

Using sendCustomAttributes

You can pass additional data about your users to provide more meaningful data along with the response. Some of the examples can be screen name, order ID, or transaction Id which can be associated with the response.

Attributes can be used to:

  • Identify respondents (by default survey responses are anonymous)

  • Trigger surveys

  • Filter survey results

Example

import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';

Map<String, String> properties = {
  'property1': 'value1',
  'property2': 'value2',
};

ZFSurvey().sendCustomAttributes(properties);

Identifying Logged-in Visitors

If you have an app where users are able to log in or signup then you can add the following code to automatically add the contacts in Zonka Feedback. You can pass at least one of the following parameters to identify the users.

Parameter
Type
Example

contact_name

string

"Josh Holland"

contact_email

string

"example@company.com"

contact_mobile

string

"+14532323223"

contac_uniqueid

string

"k2334"

Example

import 'package:zonkafeedback_sdk/zonkafeedback_sdk.dart';

Map<String, dynamic> properties = {
  'contact_name': 'Robin James',
  'contact_email': 'robin@example.com',
  'contact_uniqueId': '1XJ2',
  'contact_mobile': '+14234XXXX'
};

ZFSurvey().userInfo(properties);

Reset Visitor Attributes

If you are using the above code to identify users, then it might be a good idea to clear visitor data on logout. Use the below code to clear the data.

Example

ZFSurvey().clear();

Last updated