ecp_sync_plugin 3.1.6 copy "ecp_sync_plugin: ^3.1.6" to clipboard
ecp_sync_plugin: ^3.1.6 copied to clipboard

outdated

A new Flutter plugin. Added AES Encription, Added QR Code Scanner, File & DB Sync for Android & IOS, Internet Connectivity check for both Android & IOS.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:ecp_sync_plugin/ecp_sync_plugin.dart';
//import 'package:ecp_sync_plugin_example/DatabaseHelper.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;
  //DatabaseHelper databaseHelper;

  @override
  void initState() {
    super.initState();

    //databaseHelper = DatabaseHelper.get();
    //databaseHelper.removeLogs();
    //databaseHelper.closeDatabase();
    //databaseHelper.close();

    _batteryStateSubscription =
        _battery.onBatteryStateChanged.listen((Map state) {
      setState(() {
        _batteryState = state;
        print(state);
      });
    });
    //initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState(int type) async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.

    // 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 (type == 1) {
      /*databaseHelper = DatabaseHelper.get();
      databaseHelper.getCountLogin();*/
      platformVersion = await EcpSyncPlugin().syncronizeData(
          UserName: "636EA06F-5CFC-4AEE-AC62-575D67705D0D",
          fk_EmpGlCode: "4",
          urlUpload: "http://172.16.10.65/BASF_HK_Webservice/Services.asmx/",
          imei: "92ec11051c39aa2a",
          appVersion: "18.0.11",
          uploadMethod: "SynchronizeDatabase",
          ClientName: "BASF_HK_Device",
          databaseName: "BASF-HK-Database.db",
          packageName: "ecp.vcs.com.ecpsyncpluginexample");
      print("Internet:$platformVersion");
    } else if (type == 3) {
      /*databaseHelper = DatabaseHelper.get();
      databaseHelper.getCountLogin();*/

      platformVersion =
          await EcpSyncPlugin().scanBarCodes("false", "true", "false", "");
      print("Internet:$platformVersion");
    } else if (type == 4) {
      /*databaseHelper = DatabaseHelper.get();
      databaseHelper.getCountLogin();*/

      platformVersion = await EcpSyncPlugin().checkInternet();
      print("Internet:$platformVersion");
    } else if (type == 5) {
      /*databaseHelper = DatabaseHelper.get();
      databaseHelper.getCountLogin();*/

      platformVersion = await EcpSyncPlugin().checkBarCode("asdfasdf");
      print("Internet:$platformVersion");
    }

    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(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);
                },
              )
            ],
          ),
        ),
      ),
    );
  }

  pressDetails(int type) {
    /*Navigator.push(
      _context,
      MaterialPageRoute(
          builder: (context) => BarChartWithSecondaryAxis.withSampleData()),
    );*/

    initPlatformState(type);
  }

  @override
  void dispose() {
    super.dispose();
    print("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}
}
3
likes
0
pub points
65%
popularity

Publisher

unverified uploader

A new Flutter plugin. Added AES Encription, Added QR Code Scanner, File & DB Sync for Android & IOS, Internet Connectivity check for both Android & IOS.

Homepage

License

unknown (LICENSE)

Dependencies

flutter, json_annotation, json_serializable

More

Packages that depend on ecp_sync_plugin