ecp_sync_plugin 6.9.20 ecp_sync_plugin: ^6.9.20 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 'dart:io';
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';
String imagePath = '';
EcpSyncPlugin _battery = EcpSyncPlugin();
late Map _batteryState;
late StreamSubscription<Map> _batteryStateSubscription;
TextEditingController controller = TextEditingController();
bool imageFound = false;
@override
void initState() {
super.initState();
_batteryStateSubscription =
_battery.onBatteryStateChanged.listen((Map state) {
setState(() {
_batteryState = state;
//print(state);
try {
print('=======state=======${state.toString()}');
if (state['type'] == '2001') {
var detailsData = state['Details'];
imageFound = true;
imagePath = detailsData;
print('=======detailsData=======${detailsData.toString()}');
print('=======imagePath=======${imagePath}');
}
} catch (e) {
print(e.toString());
}
});
});
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 == 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);
},
),
RaisedButton(
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
child: Text(
"Pick Photo",
style: TextStyle(color: Colors.white),
),
color: Colors.blueGrey,
onPressed: () {
pressDetails(201);
},
),*/
new Container(
height: 100,
width: 100,
child: imageFound
? Image.file(File(imagePath))
: Image.asset("assets/download.jpeg"))
],
),
),
),
);
}
//Image.asset('assets/drawer_logo.png',
// width: p_100, height: bottom_height_50),
pressDetails(int type) {
initPlatformState(type);
}
@override
void dispose() {
super.dispose();
print("dispose");
if (_batteryStateSubscription != null) {
_batteryStateSubscription.cancel();
}
}
}