plotline_insights 1.0.0
plotline_insights: ^1.0.0 copied to clipboard
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);
}
}