Note the data plane URL present in your RudderStack dashboard.
Installing the SDK
Starting from v1.0.2, the RudderStack Flutter SDK is migrated to Null Safety.
Follow these steps to add the Flutter SDK through pub:
Open pubspec.yaml and add rudder_sdk_flutter under dependencies section:
dependencies:rudder_sdk_flutter:^2.0.1
Navigate to your application’s root folder and install all the required dependencies with the following command:
flutter pub get
If you are using Proguard full mode to optimize your app, add the lines specified in the FAQ to your Android ProGuard rules.
Installing the SDK for the web
To install and use the Flutter SDK in your web app, follow the above steps to add the Flutter SDK. Additionally, copy the following snippet in the <head> section of your web page:
This parameter should be changed only if you are self-hosting the control plane. Refer to the Self-hosted control plane section for more information. The SDK will add /sourceConfig along with this URL to fetch the configuration.
https://api.rudderlabs.com
mobileConfig parameters
The mobileConfig object contains the mobile-specific configuration parameters for the Flutter SDK.
Parameter
Type
Description
Default value
dbCountThreshold
int
Number of events to be saved in the SQLite database. Once this limit is reached, the older events are deleted from the database.
10000
sleepTimeOut
int
Minimum waiting time to flush the events to the server.
10 seconds
configRefreshInterval
int
Fetches the config from the dashboard after this specified time.
2
trackLifecycleEvents
bool
Determines if the SDK will capture application life cycle events automatically.
true
autoCollectAdvertId
bool
Determines if the SDK will collect the advertisement ID.
false
recordScreenViews
bool
When enabled, the SDK automatically records the screens viewed by the user.
false
dbEncryption
RudderDBEncryption
Specify whether to encrypt/decrypt the database using the specified key. See Encrypting RudderStack databases for more information.
-
webConfig parameters
The webConfig object contains the configuration parameters for using the SDK in the Flutter web applications.
Parameter
Type
Description
Default value
destSDKBaseURL
String
The SDK loads the integration from this path.
useBeacon
bool
If enabled, the SDK sends the event payloads via the navigator.sendBeacon() utility
False
secureCookie
bool
If enabled, the SDK sends the cookie to the storage backend via HTTPS.
False
loadIntegration
bool
If disabled, the destination SDKs are not fetched by the SDK.
If you are self-hosting RudderStack and using the Control plane lite utility to host your own control plane, then follow the steps in this section and specify the controlPlaneUrl parameter in your RudderConfigBuilder that points to the hosted configuration file.
You should not pass the controlPlaneUrl parameter during SDK initialization if you are using RudderStack Cloud. This parameter is supported only if you are using the open source Control plane lite utility to set up your own control plane.
FAQ
Do I need to add anything to my Android ProGuard rules?
If you are using Proguard full mode to optimize your app, add the following lines to your Android ProGuard rules:
// Reporter Module
-keepclasscom.rudderstack.android.ruddermetricsreporterandroid.models.LabelEntity{*;}-keepclasscom.rudderstack.android.ruddermetricsreporterandroid.models.MetricEntity{*;}-keepclasscom.rudderstack.android.ruddermetricsreporterandroid.models.ErrorEntity{*;}// Required for the usage off TypeToken class in Utils.converToMap, Utils.convertToList
-keepclasscom.google.gson.reflect.TypeToken{*;}-keepclass* extendscom.google.gson.reflect.TypeToken// Required for the serialization of SourceConfig once it is downloaded.
-keepclasscom.google.gson.internal.LinkedTreeMap{*;}-keepclass* implementsjava.io.Serializable{*;}-keepclasscom.rudderstack.rudderjsonadapter.RudderTypeAdapter{*;}-keepclass* extendscom.rudderstack.rudderjsonadapter.RudderTypeAdapter// Required to ensure the DefaultPersistenceProviderFactory is not removed by Proguard
// and works as expected even when the customer is not using encryption feature.
-dontwarnnet.sqlcipher.Cursor-dontwarnnet.sqlcipher.database.SQLiteDatabase$CursorFactory-dontwarnnet.sqlcipher.database.SQLiteDatabase-dontwarnnet.sqlcipher.database.SQLiteOpenHelper-keepclasscom.rudderstack.android.sdk.core.persistence.DefaultPersistenceProviderFactory{*;}// Required for the usage of annotations across reporter and web modules
-dontwarncom.fasterxml.jackson.annotation.JsonIgnore-dontwarncom.squareup.moshi.Json-dontwarncom.fasterxml.jackson.annotation.JsonProperty// Required for Device Mode Transformations
-keepclasscom.rudderstack.android.sdk.core.TransformationResponse{*;}-keepclasscom.rudderstack.android.sdk.core.TransformationResponseDeserializer{*;}
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.