Skip to main content

Flutter SDK Getting Started

Pub GitHub

Initializing the SDK

We recommend initializing the SDK once and pass around the client instance around in your app. Using the builder pattern we can initialize the DevCycle SDK by providing the DevCycleUser and DevCycle mobile SDK key:

import 'package:devcycle_flutter_client_sdk/devcycle_flutter_client_sdk.dart';

void main() {
runApp(const MyApp());

class MyApp extends StatefulWidget {
const MyApp({super.key});

State<MyApp> createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
static final user = DevCycleUserBuilder().isAnonymous(true).build();
static final options = DevCycleOptionsBuilder().logLevel(LogLevel.error).build();

final _devcycleClient = DevCycleClientBuilder()

void initState() {


The user object may specify a userId for a given User. If the userId is not specified, the User is considered to be anonymous.

DevCycleClient Builder

The DevCycleClient can be built using the following methods:

DevCycleClientBuilder class

sdkKeyStringDevCycle SDK Key
userDevCycleUserDevCycleUser object
optionsDevCycleOptionsDevCycleOptions object

DevCycleUser Builder

The DevCycleUser can be built using the following methods:

DevCycleUserBuilder class

userIdStringUnique user ID
isAnonymousBoolBoolean to indicate if the user is anonymous
emailStringUser's email
nameStringUser's name
languageStringUser's language
countryStringUser's country
customData[String: Any]Key/value map of properties to be used for targeting
privateCustomData[String: Any]Key/value map of properties to be used for targeting. Private properties will not be included in event logging.

DevCycleOptions Builder

The SDK exposes various initialization options which can be used by passing a DevCycleOptions object to the options method of DevCycleClient.builder():

DevCycleOptionsBuilder class

flushEventsIntervalMsInt10000Controls the interval between flushing events to the DevCycle servers in milliseconds, defaults to 10 seconds.
disableCustomEventLoggingBooleanfalseDisables logging of custom events generated by calling .track() method to DevCycle.
disableAutomaticEventLoggingBooleanfalseDisables logging of SDK generated events (e.g. variableEvaluated, variableDefaulted) to DevCycle.
logLevelLogLevelerrorSet log level of the default logger. Defaults to error
enableEdgeDBBooleanfalseEnables the usage of EdgeDB for DevCycle that syncs User Data to DevCycle.
configCacheTTLInt604800000The maximum allowed age of a cached config in milliseconds, defaults to 7 days
disableConfigCacheBoolfalseDisable the use of cached configs
disableRealtimeUpdatesBoolfalseDisable Realtime Updates

Notifying when DevCycle features are available

In the initialize call there is an optional onInitialized parameter you can use to determine when your features have been loaded:

final _devcycleClient = DevCycleClientBuilder()
.onInitialized((error) {