ecp_sync_plugin 3.8.1 copy "ecp_sync_plugin: ^3.8.1" to clipboard
ecp_sync_plugin: ^3.8.1 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 'SecondHome.dart';
//import 'package:http/http.dart' as http;
//import 'dart:convert' show utf8;

//import 'package:flutter_sqlcipher/sqlite.dart';
//import 'package:path_provider/path_provider.dart';
//import 'package:path/path.dart';

//import 'dart:io';

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;
  TextEditingController controller = TextEditingController();

  //BuildContext _context;
  //DatabaseHelper databaseHelper;

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

    //databaseHelper = DatabaseHelper.get();
    print("*************************************");
    //databaseHelper.getCountLogin();
    print("*************************************");
    //databaseHelper.removeLogs();
    //databaseHelper.closeDatabase();
    //databaseHelper.close();

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

    controller.addListener(() {
      // Do something here
      print("Test::${controller.text}");
    });
    //initPlatformState();
  }

  /*Future migrateToPlainText() async {
    print("start migration");
    File newFile = await _getLocalFile();
    newFile.createSync();

    Directory documentsDirectory = await getApplicationDocumentsDirectory();
    String path = join(documentsDirectory.path, "database.db");
    File legacyFile = new File(path);

    SQLiteDatabase db =
        await SQLiteDatabase.openDatabase(path, password: "Vcs@1234");

    db.execSQL("ATTACH DATABASE '${newFile.path}' AS plaintext KEY '';");
    db.execSQL("SELECT sqlcipher_export('plaintext')");
    db.execSQL("DETACH DATABASE plaintext;");
    Future<int> version = db.getVersion();
    db.close();
    db = await SQLiteDatabase.openOrCreateDatabase(newFile.path);
    version.then((int value) {
      db.setVersion(value);
      legacyFile.delete();
      newFile.rename(legacyFile.path);
      db.close();
      print("migrated to text");
    });
  }*/

  // 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.

    //Route route = MaterialPageRoute(builder: (context) => SecondHome());
    //Navigator.push(context, route);

    //platformVersion = await EcpSyncPlugin().checkSqliteChiper(androidDBPath, flutterDBPath)
    //platformVersion = await EcpSyncPlugin().restorePreferences();

    //platformVersion = await EcpSyncPlugin().hideKeyboardPlugin();

    /*platformVersion = await EcpSyncPlugin().syncronizeDataFile(
        userName: "9D469C06-65C7-41AF-9278-1C8F98230885",
        fkEmpGlCode: "98",
        urlUpload: "http://172.16.9.6/BASF_HK_Webservice_IQA/Services.asmx/",
        iMei: "F66EE8AC-C592-4B9B-97AB-E27D6134306B",
        appVersion: "19.1.16",
        uploadMethod: "SynchronizeFile",
        logUploadMethod: "DeviceSyncLog",
        clientName: "BASF_HK_FLUTTER_IOS",
        databaseName: "BASF-HK-Database.db",
        packageName: "ecp.vcs.com.ecpsyncpluginexample");*/

    /* platformVersion = await EcpSyncPlugin().syncronizeData(
        userName: "697514B3-78DB-4FCC-AFA9-9387BE35AB7D",
        fkEmpGlCode: "4",
        urlUpload: "http://172.16.10.65/BASF_HK_Webservice/Services.asmx/",
        iMei: "CE976921-4AA1-4FC5-B446-7EF21CE45A4B",
        appVersion: "18.0.11",
        uploadMethod: "Synchronize",
        logUploadMethod: "DeviceSyncLog",
        clientName: "BASF_HK_Device",
        databaseName: "BASF-HK-Database.db",
        packageName: "ecp.vcs.com.ecpsyncpluginexample");*/

    /*platformVersion = await EcpSyncPlugin().syncronizeData(
        userName: "697514B3-78DB-4FCC-AFA9-9387BE35AB7D",
        fkEmpGlCode: "4",
        urlUpload: "http://172.16.10.65/BASF_HK_Webservice/Services.asmx/",
        iMei: "CE976921-4AA1-4FC5-B446-7EF21CE45A4B",
        appVersion: "18.0.11",
        uploadMethod: "SynchronizeDatabase",
        clientName: "BASF_HK_Device",
        databaseName: "BASF-HK-Database.db",
        packageName: "ecp.vcs.com.ecpsyncpluginexample",
        dbPassword: "Vcs@1234",
        isDbEncripted: "false");

    print("encode:$platformVersion");*/

    /*platformVersion = await EcpSyncPlugin()
        .scanBarCodes("true", "true", "false", "#ffffff", "true");
    print("encode:$platformVersion");*/

    platformVersion = await EcpSyncPlugin().pickFileFromGallary("Android", "2");
    print("encode:$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'),
              /*Container(
                  child: ExtendedImage.network(
                'https://i.imgur.com/tKg0XEb.jpg',
                fit: BoxFit.contain,
                //enableLoadState: false,
                mode: ExtendedImageMode.Gesture,
                gestureConfig: GestureConfig(
                    minScale: 0.9,
                    animationMinScale: 0.7,
                    maxScale: 3.0,
                    animationMaxScale: 3.5,
                    speed: 1.0,
                    inertialSpeed: 100.0,
                    initialScale: 1.0,
                    inPageView: false),
              )*/ /*PinchZoomImage(
                  image: Image.network('https://i.imgur.com/tKg0XEb.jpg'),
                  zoomedBackgroundColor: Color.fromRGBO(240, 240, 240, 1.0),
                  hideStatusBarWhileZooming: true,
                  onZoomStart: () {
                    print('Zoom started');
                  },
                  onZoomEnd: () {
                    print('Zoom finished');
                  },
                ),*/
              // ),
              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);
                },
              ),
              TextField(
                controller: controller,
                decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: 'Please enter a search term'),
              ),
            ],
          ),
        ),
      ),
    );
  }

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

    initPlatformState(type);
  }

  /*Future<File> _getLocalFile() async {
    // get the path to the document directory.
    String dir = (await getApplicationDocumentsDirectory()).path;
    return new File('$dir/counter.db');
  }*/

  /*Future _onCreate(SQLiteDatabase db, int newVersion) async {
    // When creating the db, create the table
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CPM_CUSTOMER_DISPATCH);
    await db.execSQL(
        DatabaseQuery.CREATE_TABLE_CPM_CUSTOMER_DISPATCH_PRODUCT_DETAILS);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CPM_CUSTOMER_RECEIVE);
    await db.execSQL(
        DatabaseQuery.CREATE_TABLE_CPM_CUSTOMER_RECEIVE_PRODUCT_DETAILS);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CPM_STRICKER_Details);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_STATUS_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_PRODUCT_SKU_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_COUNTRY_MST);
    await db.execSQL(
        DatabaseQuery.CREATE_TABLE_POLITICAL_GEOGRAPHY_LEVEL_REGIONAL_MST);
    await db.execSQL(
        DatabaseQuery.CREATE_TABLE_POLITICAL_GEOGRAPHY_LEVEL_COUNTRY_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_POLITICAL_GEOGRAPHY_DETAILS);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_SYSTEM_CONFIGURATION_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_EMPLOYEE_TYPE_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CUSTOMER_TYPE_REGIONAL_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CUSTOMER_TYPE_COUNTRY_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_PERSON_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_UOM_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_MENU_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_PSKU_BATCH_STOCK);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CUSTOMER_PARTNER_MST);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_CPM_CUSTOMER_STICKER_DAMAGE);
    await db.execSQL(DatabaseQuery.CREATE_TABLE_LOGIN_DETAILS);
    await db
        .execSQL(DatabaseQuery.CREATE_TABLE_CPM_CUSTOMER_STICKER_DAMAGE_REMOVE);

    String INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_btc_out_sticker ON cpm_sticker_details (varBTC_No_Out)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_qr_code_out_sticker ON cpm_sticker_details (varQR_Code_Out)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_varDONO ON CPM_Customer_Dispatch (varDONO)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_fk_Customer_From_GlCode ON CPM_Customer_Dispatch (fk_Customer_From_GlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_fk_Customer_To_GlCode ON CPM_Customer_Dispatch (fk_Customer_To_GlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_fk_Product_SKU_Glcode ON CPM_Customer_Dispatch_Product_Details (fk_Product_SKU_Glcode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_fk_Customer_DispatchGlCode ON CPM_Customer_Dispatch_Product_Details (fk_Customer_DispatchGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_fk_StickerGlCode ON CPM_Customer_Dispatch_Product_Details (fk_StickerGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Dispatch_varSticker ON CPM_Customer_Dispatch_Product_Details (varSticker)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_Product_Details_varSticker ON CPM_Customer_Receive_Product_Details (varSticker)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Sticker_Damage_varSticker ON CPM_Customer_Sticker_Damage (varSticker)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_fk_DispatchGlCode ON CPM_Customer_Receive (fk_DispatchGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_fk_Customer_From_GlCode ON CPM_Customer_Receive (fk_Customer_From_GlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_fk_Customer_To_GlCode ON CPM_Customer_Receive (fk_Customer_To_GlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_Product_Details_fk_Product_SKU_Glcode ON CPM_Customer_Receive_Product_Details (fk_Product_SKU_Glcode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_Product_Details_fk_Customer_ReceiveGlCode ON CPM_Customer_Receive_Product_Details (fk_Customer_ReceiveGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Receive_Product_Details_fk_StickerGlCode ON CPM_Customer_Receive_Product_Details (fk_StickerGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Sticker_Damage_fk_CustomerGlCode ON CPM_Customer_Sticker_Damage (fk_CustomerGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Customer_Sticker_Damage_fk_StickerGlCode ON CPM_Customer_Sticker_Damage (fk_StickerGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Sticker_Details_fk_CustomerGlCode ON CPM_Sticker_Details (fk_CustomerGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Sticker_Details_fk_Product_SKUGlCode ON CPM_Sticker_Details (fk_Product_SKUGlCode)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Sticker_Details_varBatch_No ON CPM_Sticker_Details (varBatch_No)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Sticker_Details_fk_Sticker_GeneratedBy ON CPM_Sticker_Details (fk_Sticker_GeneratedBy)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Sticker_Details_fk_Last_DispatchedTo ON CPM_Sticker_Details (fk_Last_DispatchedTo)";
    await db.execSQL(INDEX_QUERY);

    INDEX_QUERY =
        "CREATE INDEX IF NOT EXISTS idx_CPM_Sticker_Details_fk_Last_DispatchedBy ON CPM_Sticker_Details (fk_Last_DispatchedBy)";
    await db.execSQL(INDEX_QUERY);

    String CREATE_TEMP =
        "CREATE TABLE IF NOT EXISTS CPM_TEMP_BULK(intGlCode INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,intRowNo INTEGER,stickerNo TEXT,stickerId TEXT,chrValid TEXT)";
    await db.execSQL(CREATE_TEMP);
  }*/

  @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
64%
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