kameleoon_client_flutter 3.4.0 copy "kameleoon_client_flutter: ^3.4.0" to clipboard
kameleoon_client_flutter: ^3.4.0 copied to clipboard

Our SDK gives you the possibility of running experiments and activating feature flags on all platforms targeted by the Flutter application framework.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kameleoon_client_flutter/kameleoon_client_flutter.dart';
import 'package:kameleoon_client_flutter_example/Pages/Main/main_page.dart';
import 'package:kameleoon_client_flutter_example/constants.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Color _color = Color.fromRGBO(100, 100, 255, 1);

  @override
  void initState() {
    super.initState();
    initKameleoon();
  }

  Future<void> initKameleoon() async {
    KameleoonClient client = KameleoonClientFactory.create("<siteCode>");

    client.runWhenReady((ready) async {
      if (!ready) {
        print("Kamleeoon SDK: Not initiliazed after timeout");
        return;
      }
      try {
          final visitorCode = await client.getVisitorCode();
          print(visitorCode);
          String? color = await client.getFeatureVariable("color-feature-flag", "color") as String?;
          color = "FF" + color!.toUpperCase().replaceAll("#", "");
          mainColor = Color(int.parse(color, radix: 16));
          setState(() {
            _color = Color(int.parse(color!, radix: 16));
          });
      } on FeatureNotFound {
      } on FeatureVariableNotFound {
      } on PlatformException {
      } on Exception {
      }
    }, Duration(seconds: 5));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Kameleoon Plugin Demo",
      theme: ThemeData(
        primaryColor: _color,
        scaffoldBackgroundColor: bgColor
      ),
      home: MainPage(),
      debugShowCheckedModeBanner: false,
    );
  }
}
0
likes
130
points
1.44k
downloads

Publisher

unverified uploader

Weekly Downloads

Our SDK gives you the possibility of running experiments and activating feature flags on all platforms targeted by the Flutter application framework.

Homepage

Documentation

API reference

License

LGPL-3.0 (license)

Dependencies

flutter, flutter_web_plugins, js

More

Packages that depend on kameleoon_client_flutter