contlo_plugin 0.0.1-beta
contlo_plugin: ^0.0.1-beta copied to clipboard
Contlo Flutter Plugin
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:contlo_plugin/contlo_plugin.dart';
import 'user_screen.dart';
import 'dummy_event_screen.dart';
import 'event_screen.dart';
final API_KEY = "<CONTLO_API_KEY>";
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage()
);
}
}
class HomePage extends StatelessWidget {
String _platformVersion = 'Unknown';
final _contloPlugin = ContloPlugin();
HomePage() {
init();
}
void init() async {
String? dd = await _contloPlugin.init(API_KEY) as String?;
print("initialized contlo: $dd");
// Add your code here for the third button
}
// 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 _contloPlugin.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.
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Contlo Plugin'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center, // Align buttons vertically in the center
children: <Widget>[
ElevatedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => UserScreen()));
},
child: Text('Send User Detail'),
),
ElevatedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => EventScreen()));
},
child: Text('Send Event'),
),
ElevatedButton(
onPressed: () async {
String? dd = await _contloPlugin.sendAdvertisingId(true);
print("Advertising ID: $dd");
// Add your code here for the third button
},
child: Text('Send Advertising ID'),
),
ElevatedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => DummyEventScreen()));
},
child: Text('Dummy Events'),
),
],
),
),
),
);
}
}