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

outdated

Our SDK gives you the possibility of running experiments and activating feature flags on all platforms targeted by the Flutter application framework. Integrating our SDK into your applications is easy [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kameleoon_client_flutter/kameleoon_client.dart';
import 'package:kameleoon_client_flutter/kameleoon_client_factory.dart';
import 'package:kameleoon_client_flutter/kameleoon_exception.dart' as KameleoonException;
import 'package:kameleoon_client_flutter/kameleoon_data.dart' as KameleoonData;
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() {
    KameleoonClient client = KameleoonClientFactory.create("SITE_CODE");

    client.runWhenReady(() async {
      String visitorCode = await client.obtainVisitorCode();
      try {
        bool ff = await client.activateFeature(visitorCode, "color-feature-flag");
        if (ff) {
          String color = await client.obtainFeatureVariable("color-feature-flag", "color");
          color = "FF" + color.toUpperCase().replaceAll("#", "");
          mainColor = Color(int.parse(color, radix: 16));
          setState(() {
            _color = Color(int.parse(color, radix: 16));
          });
        }
      } on KameleoonException.FeatureConfigurationNotFound {
      } on KameleoonException.NotTargeted {
      } on PlatformException {
      }
    }, () {
      print("TIMEOUT");
    }, 1000);
  }

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

Publisher

unverified uploader

Our SDK gives you the possibility of running experiments and activating feature flags on all platforms targeted by the Flutter application framework. Integrating our SDK into your applications is easy, and its footprint (in terms of memory and network usage) is low.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on kameleoon_client_flutter