plotline_engage_web 1.0.5
plotline_engage_web: ^1.0.5 copied to clipboard
Flutter Web plugin for seamless integration of Plotline, a platform empowering growth and marketing teams to improve feature adoption and activation with in-app messages
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:plotline_engage_web/plotline.dart';
import 'package:plugin_plotline_example/routing/delegate.dart';
import 'package:plugin_plotline_example/routing/parser.dart';
import 'package:plugin_plotline_example/routing/route_state.dart';
import 'screens/home.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> {
final _navigatorKey = GlobalKey<NavigatorState>();
late final RouteState _routeState;
late final SimpleRouterDelegate _routerDelegate;
late final TemplateRouteParser _routeParser;
@override
void initState() {
_routeParser = TemplateRouteParser(
allowedPaths: [
'/home',
'/artists',
'/songs',
'/song/:songId',
'/artist/:artistId',
],
initialRoute: '/home',
);
_routeState = RouteState(_routeParser);
_routerDelegate = SimpleRouterDelegate(
routeState: _routeState,
navigatorKey: _navigatorKey,
builder: (context) => HomePage(
navigatorKey: _navigatorKey,
),
);
Plotline.init("<apiKey>", "<userId>", endpoint: "https://api.plotline.so");
Plotline.debug(true);
Plotline.setPlotlineEventsListener((eventName, properties) => {
// Your callback implementation here
print("Plotline Callback for event: $eventName with properties: $properties")
});
Plotline.setPlotlineRedirectListener((properties) => {
// Your callback implementation here
print("Plotline Redirect Callback with properties: $properties")
});
super.initState();
}
@override
void dispose() {
_routeState.dispose();
_routerDelegate.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return PlotlineWrapper(
child: RouteStateScope(
notifier: _routeState,
child: MaterialApp.router(
routerDelegate: _routerDelegate,
routeInformationParser: _routeParser,
),
)
);
}
}