test_plugin_fftt_test 0.0.3
test_plugin_fftt_test: ^0.0.3 copied to clipboard
A test Flutter plugin .
example/lib/main.dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:test_plugin_fftt_test/test_plugin_fftt_test.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> {
var textInput = TextEditingController();
final _testPluginFfttTestPlugin = TestPluginFfttTest();
@override
void initState() {
super.initState();
initPlatformState();
}
/// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
var result = await _testPluginFfttTestPlugin
.initSDK("Your Key");
_testPluginFfttTestPlugin.setLogVisible(true);
if (kDebugMode) {
print("CONNECTION LISTENER :: :::::::::::: ");
print(result);
}
if (!mounted) return;
setState(() {
//_platformVersion = platformVersion;
});
}
Future<void> onStartStopTrip(bool isStart) async {
if (kDebugMode) {
print("FROM INSIDE ON START STOP TRIP ");
}
if (textInput.text.trim().isNotEmpty) {
try {
var result;
if (isStart) {
result = await _testPluginFfttTestPlugin
.startTrip(textInput.text.toString());
} else {
result = await _testPluginFfttTestPlugin
.stopTrip(textInput.text.toString());
}
if (kDebugMode) {
print("ON START STOP RESULT MEHTOD CALLING :::: ");
print(result);
}
} on Exception catch (exception) {
exception.runtimeType;
}
} else {
if (kDebugMode) print("Enter TRIP ID");
}
}
Future<void> onStartStopTrack(bool isTrack) async {
if (textInput.text.trim().isNotEmpty) {
try {
if (isTrack) {
_testPluginFfttTestPlugin.startTracking(textInput.text.toString());
} else {
_testPluginFfttTestPlugin.stopTracking(textInput.text.toString());
}
} on Exception catch (exception) {
exception.runtimeType;
}
} else {
if (kDebugMode) print("Enter TRIP ID");
}
}
Future<void> onStartStopMultiTrack(bool isTrack) async {
if (textInput.text.trim().isNotEmpty) {
try {
if (isTrack) {
_testPluginFfttTestPlugin.startMultiTracking(textInput.text.toString());
} else {
_testPluginFfttTestPlugin.startMultiTracking(textInput.text.toString());
}
} on Exception catch (exception) {
exception.runtimeType;
}
} else {
if (kDebugMode) print("Enter TRIP ID");
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.all(10),
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.grey.shade300,
),
child: TextField(
controller: textInput,
decoration: const InputDecoration(
border: InputBorder.none, hintText: "Enter a Trip ID"),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
onStartStopTrack(true);
},
child: const Text("Start tracking"),
),
const SizedBox(
width: 15,
),
ElevatedButton(
onPressed: () {
onStartStopTrack(false);
},
child: const Text("Stop tracking"),
),
],
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
onStartStopMultiTrack(true);
},
child: const Text("Start M tracking"),
),
const SizedBox(
width: 15,
),
ElevatedButton(
onPressed: () {
onStartStopMultiTrack(false);
},
child: const Text("Stop M tracking"),
),
],
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
onStartStopTrip(true);
},
child: const Text("Start Trip"),
),
const SizedBox(
width: 15,
),
ElevatedButton(
onPressed: () {
onStartStopTrip(false);
},
child: const Text("Stop trip"),
),
],
)
],
),
),
),
);
}
}