ecp_sync_plugin 1.1.1 ecp_sync_plugin: ^1.1.1 copied to clipboard
A new Flutter plugin. Added AES Encription for IOS & Android
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:ecp_sync_plugin/ecp_sync_plugin.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
/*class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(home: new _MyAppState());
}
}*/
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
EcpSyncPlugin _battery = EcpSyncPlugin();
Map _batteryState;
StreamSubscription<Map> _batteryStateSubscription;
//BuildContext _context;
@override
void initState() {
super.initState();
_batteryStateSubscription =
_battery.onBatteryStateChanged.listen((Map state) {
setState(() {
_batteryState = state;
});
});
//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.
try {
/*platformVersion = await EcpSyncPlugin().syncronizeData(
UserName: "",
fk_EmpGlCode: "",
urlUpload: "",
imei: "",
appVersion: "",
uploadMethod: "",
ClientName: "",
databaseName: "",
packageName: "");*/
platformVersion = await EcpSyncPlugin()
.encodeData("Vcs@1234", "B4V2A1C@S#S\$F", "0000000000000000");
print("encode:$platformVersion");
platformVersion = await EcpSyncPlugin()
.decodeData(platformVersion, "B4V2A1C@S#S\$F", "0000000000000000");
print("decode:$platformVersion");
/* platformVersion = await EcpSyncPlugin().decodeData(
"jb3glSJJmz6SIgg3CvxBFA==", "B4V2A1C@S#S\$F", "1234567890123456");
print("from IOS decode:$platformVersion");*/
/*String kkkey = "B4V2A1C@S#S\$F";
print("kkkey:$kkkey");
final plainText =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
final key = Ddevs.Key.fromUtf8(kkkey);
final iv = Ddevs.IV.fromLength(16);
final encrypter = Ddevs.Encrypter(Ddevs.AES(key, iv));
final encrypted = encrypter.encrypt(plainText);
final decrypted = encrypter.decrypt(encrypted);
print(
decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
print(encrypted.base64);*/
} 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;
});
}
@override
Widget build(BuildContext context) {
//_context = context;
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('ECP Plugin Sync'),
),
body: /*BarChartWithSecondaryAxis
.withSampleData() */
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: () {
//dismissProgressHUD();
pressDetails();
},
)
],
),
),
),
);
}
pressDetails() {
/*Navigator.push(
_context,
MaterialPageRoute(
builder: (context) => BarChartWithSecondaryAxis.withSampleData()),
);*/
//DatabaseHelper dbAdapter = DatabaseHelper.get();
//dbAdapter.getCountLogin();
initPlatformState();
}
@override
void dispose() {
super.dispose();
if (_batteryStateSubscription != null) {
_batteryStateSubscription.cancel();
}
}
//{DeviceId=353490062185257, PersonId=3, Version=18.0.11, Date=2019-02-18 11:27:18, APIToken=25425FD4-D981-4574-B83A-AC2067AA2C8C, SubModuleName=BASF_HK_Device}
}