Skip to main content

Flutter SDK best practice

Mobile application performance is critical to your business. Our technology is focused on improving your customer's experience with your app. As such, screen performance is a core component of our solutions. To boost engagement and conversion rates, we employ several approaches to minimize screen load times.

Initializing with Fonts

note

This functionality is supported from version 4.2.0 of the Rokt Flutter SDK.

Instead of or in addition to supplying your desired fonts on One Platform, you may choose to utilize the fonts already bundled with your application. This carries the advantage of removing the potential for fonts to be downloaded at initialization time, reducing network utilization and the chances of download errors.

You must provide the font postscript names and filepaths if you wish the utilize this functionality. The postscript names should match those being used in your layout, please check with your account manager if you are unsure.

note

Your fonts should be defined in your pubspec.yaml to utilize this functionality. You should pass the same filepath as defined in your pubspec.yaml for each font. See https://docs.flutter.dev/cookbook/design/fonts#declare-the-font-in-the-pubspecyaml-file for more details.

import 'package:rokt_sdk/rokt_sdk.dart';

RoktSdk.initialize('222', appVersion: '1.0.0', fontFilePathMap: {"Arial-Bold": "fonts/Arial-Bold.ttf"});

Using App Configurations

Applications can now send configuration settings from their own application environment. This allows Rokt SDK to use application custom configurations instead of relying solely on system defaults.

ColorMode object

ValueDescription
lightApplication is in Light Mode
darkApplication is in Dark Mode
systemApplication defaults to System Color Mode
// if application supports only Light Mode.
RoktConfig roktConfig =
RoktConfig(colorMode: ColorMode.light);
RoktSdk.execute(
// other params,
roktConfig: roktConfig,
)

CacheConfig object

ParameterDescription
cacheDurationOptional duration in seconds for which the Rokt SDK should cache the experience. Maximum allowed value is 90 minutes and the default (if value is not provided or invalid) is 90 minutes.
cacheAttributesOptional attributes to be used as cache key. If null, all the attributes sent in Rokt.execute will be used as the cache key.
// to cache the experience for 1200 seconds, using email and orderNumber attributes as the cache key.
RoktConfig roktConfig = RoktConfig(cacheConfig: CacheConfig(
cacheDurationInSeconds: 1200,
cacheAttributes: {"email": "j.smith@example.com", "orderNumber": "123"}));
RoktSdk.execute(
// other params,
roktConfig: roktConfig,
)

For more information see how-to section.

Was this article helpful?