restestplugin 0.0.1
restestplugin: ^0.0.1 copied to clipboard
This is the new test plugin.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:restestplugin/restestplugin.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _restestpluginPlugin = Restestplugin();
@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 _restestpluginPlugin.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;
});
}
Future<void> _sdkRegistration() async {
var token = "";
// if(Platform.isIOS){
// token =
// await platform.invokeMethod('fcmToken');
// }else{
// token = fcmToken;
// }
var data = {
"userUniqueId": "[email protected]",
"name": "",
"email": "[email protected]",
"phone": "",
"age": "",
"gender": "",
"profileUrl": "",
"dob": "",
"education": "",
"employed": true,
"married": true,
"token":"token",
"dynamicLink": {
"applinks": "visionbanknative1.page.link",
"storeId": "1289654399"
}
};
try {
var name = _restestpluginPlugin.sdkRegistration(data);
} on PlatformException catch (e) {
// print(e.message);
}
}
Future<void> _customEvent() async {
var data = {
"name": "payment",
"data": {"id": "2d43", "price": "477"}
};
try {
var name = _restestpluginPlugin.customEvent(data);
} on PlatformException catch (e) {
//print(e.message);
}
}
Future<void> _locationUpdate() async {
var data = {
"lat": 13.0827,
"long": 80.2707,
};
try {
var name = _restestpluginPlugin.locationUpdate(data);
} on PlatformException catch (e) {
// print(e.message);
}
}
Future<void> _getNotificationList() async {
var data = {
"lat": 13.0827,
"long": 80.2707,
};
try {
var name = await _restestpluginPlugin.getNotificationList();
print("NL : $name");
} on PlatformException catch (e) {
// print(e.message);
}
}
Future<void> _getNotficationUnReadCount() async {
try {
var name = await _restestpluginPlugin.getUnReadNotificationCount();
print("URNC : $name");
} on PlatformException catch (e) {
print(e.message);
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
"Welcome to Resulticks SDK" ,
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
),
),
SizedBox(
width: double.infinity, // specific value
child: ElevatedButton(
child: const Text("SDK registration"),
onPressed: _sdkRegistration,
),
),
SizedBox(
width: double.infinity, // specific value
child: ElevatedButton(
child: const Text("CustomEvent"),
onPressed: _customEvent,
),
),
SizedBox(
width: double.infinity, // specific value
child: ElevatedButton(
child: const Text("Location update"),
onPressed: _locationUpdate,
),
),
SizedBox(
width: double.infinity, // specific value
child: ElevatedButton(
child: const Text("UnRead Count"),
onPressed: _getNotficationUnReadCount,
),
)
]
),
),
);
}
}