plotline 1.2.1 copy "plotline: ^1.2.1" to clipboard
plotline: ^1.2.1 copied to clipboard

outdated

This is the official flutter plugin for Plotline's Android SDK.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:plotline/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';
  final _plotlinePlugin = Plotline();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await _plotlinePlugin.getPlatformVersion() ?? 'Unknown platform version';

    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @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(25),
            child: Text('Running on: $_platformVersion\n'),
          ),
          Container(
            margin: EdgeInsets.all(25),
            child: FlatButton(
              child: Text('Show Mock Study', style: TextStyle(fontSize: 20.0),),
              color: Colors.blueAccent,
              textColor: Colors.white,
              onPressed: _showMockStudy,
            ),
          ),
          Container(
            margin: EdgeInsets.all(25),
            child: FlatButton(
              child: Text('Init', style: TextStyle(fontSize: 20.0),),
              color: Colors.blueAccent,
              textColor: Colors.white,
              onPressed: _init,
            ),
          ),
          Container(
            margin: EdgeInsets.all(25),
            child: FlatButton(
              child: Text('Trigger #1', style: TextStyle(fontSize: 20.0),),
              color: Colors.blueAccent,
              textColor: Colors.white,
              onPressed: _track,
            ),
          ),
          Container(
            margin: EdgeInsets.all(25),
            child: FlatButton(
              child: Text('Identify', style: TextStyle(fontSize: 20.0),),
              color: Colors.blueAccent,
              textColor: Colors.white,
              onPressed: _identify,
            ),
          ),
          Container(
            margin: EdgeInsets.all(25),
            child: FlatButton(
              child: Text('Composite Trigger', style: TextStyle(fontSize: 20.0),),
              color: Colors.blueAccent,
              textColor: Colors.white,
              onPressed: _compositeTrack,
            ),
          ),
        ]))
      ),
    );
  }

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

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

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

  _identify() {
    print('Identify attribute');
    Plotline.identify({
        "key": "value"
    });
  }

  _compositeTrack() {
      print('Tracking Composite Event');
      Plotline.track("<Main Code Event>", properties: {"key": "value"});
  }
}
4
likes
0
points
88
downloads

Publisher

unverified uploader

Weekly Downloads

This is the official flutter plugin for Plotline's Android SDK.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on plotline

Packages that implement plotline