ecp_sync_plugin 4.0.0+4 ecp_sync_plugin: ^4.0.0+4 copied to clipboard
A new Flutter plugin. Added AES Encription, Added QR Code Scanner, File & DB Sync for Android & IOS, Internet Connectivity check for both Android & IOS.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:ecp_sync_plugin/ecp_sync_plugin.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
EcpSyncPlugin _battery = EcpSyncPlugin();
Map _batteryState;
StreamSubscription<Map> _batteryStateSubscription;
TextEditingController controller = TextEditingController();
@override
void initState() {
super.initState();
_batteryStateSubscription =
_battery.onBatteryStateChanged.listen((Map state) {
setState(() {
_batteryState = state;
print(state);
});
});
controller.addListener(() {
// Do something here
print("Test::${controller.text}");
});
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState(int type) async {
String platformVersion;
if (type == 3) {
String descriptionData = await EcpSyncPlugin().scanBarCodes(
"true", "true", "false", "#ffffff", "false", "Nexxt", "Scan here");
print("return:$descriptionData");
}
if (type == 100) {
String descriptionData = await EcpSyncPlugin().startScanChiperLab();
print("return:$descriptionData");
} else if (type == 200) {
String descriptionData = await EcpSyncPlugin().stopScanChiperLab();
print("return:$descriptionData");
}
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
//_context = context;
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('ECP Plugin Sync'),
),
body: Center(
child: Column(
children: <Widget>[
Text('Running on: $_platformVersion\n'),
Text('Progress on: $_batteryState\n'),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"SYNC",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
pressDetails(1);
},
),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"File Sync",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
//dismissProgressHUD();
pressDetails(2);
},
),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"Scan",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
//dismissProgressHUD();
pressDetails(3);
},
),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"Internet",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
//dismissProgressHUD();
pressDetails(4);
},
),
TextField(
controller: controller,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Please enter a search term'),
),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"Scan start ch",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
//dismissProgressHUD();
pressDetails(100);
},
),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"Scan stop ch",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
pressDetails(200);
},
),
],
),
),
),
);
}
pressDetails(int type) {
initPlatformState(type);
}
@override
void dispose() {
super.dispose();
print("dispose");
if (_batteryStateSubscription != null) {
_batteryStateSubscription.cancel();
}
}
}