ecp_sync_plugin 5.0.0+1 copy "ecp_sync_plugin: ^5.0.0+1" to clipboard
ecp_sync_plugin: ^5.0.0+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 '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();
  Map _batteryState;
  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 == 3) {
      /*String descriptionData = await EcpSyncPlugin().scanBarCodes(
          "true", "true", "false", "#ffffff", "false", "Nexxt", "Scan here");
      print("return:$descriptionData");*/

      String descriptionData = await EcpSyncPlugin().checkPermission("Android");
      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");
    } else if (type == 201) {
      String descriptionData = await EcpSyncPlugin()
          .pickFileFromGallary(Platform.isAndroid ? "android" : "IOS", "1");
      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();
    }
  }
}
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