plotline_insights 2.0.0 copy "plotline_insights: ^2.0.0" to clipboard
plotline_insights: ^2.0.0 copied to clipboard

outdated

The official flutter plugin for Plotline's SDK

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';

import 'package:plotline_insights/plotline.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plotline Plugin Test App'),
        ),
        body: Center(child: Column(children: <Widget> [
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Show Mock Study', style: TextStyle(fontSize: 20.0),),
              onPressed: _showMockStudy,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Init', style: TextStyle(fontSize: 20.0),),
              onPressed: _init,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Trigger #1', style: TextStyle(fontSize: 20.0),),
              onPressed: _track,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Identify', style: TextStyle(fontSize: 20.0),),
              onPressed: _identify,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Composite Trigger', style: TextStyle(fontSize: 20.0),),
              onPressed: _compositeTrack,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Set Locale(en)', style: TextStyle(fontSize: 20.0),),
              onPressed: _setLocaleEn,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Set Locale(hi)', style: TextStyle(fontSize: 20.0),),
              onPressed: _setLocaleHi,
            ),
          ),
          Container(
            margin: EdgeInsets.all(15),
            child: TextButton(
              child: Text('Set Color', style: TextStyle(fontSize: 20.0),),
              onPressed: _setColor,
            ),
          ),
        ]))
      ),
    );
  }

  _init() {
    print('Init started');
    Plotline.init("<apiKey>", "<userId>");
  }

  _showMockStudy() {
    print('Showing Mock study');
    Plotline.showMockStudy();
  }

  _track() {
    print('Tracking Event');
    Plotline.track("<eventName>");
  }

  _identify() {
    print('Identify attribute');
    Plotline.identify({
        "<attributeName>": "<attributeValue"
    });
  }

  _setLocaleEn() {
    print("Setting English locale");
    Plotline.setLocale("en");
  }

  _setLocaleHi() {
    print("Setting Hindi locale");
    Plotline.setLocale("hi");
  }

  _compositeTrack() {
    print('Tracking Composite Event');
    Plotline.track("<compositeEventName>", properties: {"name": "value"});
  }

  _setColor() {
    print("Setting colors");
    const colors = {
      "background": "#f5f2f7",
      "description": "#800080",
      "title": "#9405fa",
      "optionText": "#9405fa",
      "optionBackground": "#03000000",
      "optionBorder": "#230a36",
      "buttonBackground": "#ffffff",
      "buttonText": "#9405fa",
      "progressValue": "#001100",
      "progressBackground": "#30808080"
    };
    Plotline.setColor(colors);
  }
}
1
likes
0
points
13
downloads

Publisher

verified publisherplotline.so

Weekly Downloads

The official flutter plugin for Plotline's SDK

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on plotline_insights

Packages that implement plotline_insights