ecp_sync_plugin 6.9.29 copy "ecp_sync_plugin: ^6.9.29" to clipboard
ecp_sync_plugin: ^6.9.29 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.

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 = '';
  final EcpSyncPlugin _battery = EcpSyncPlugin();
  Map<dynamic, dynamic> _batteryState = {};
  late StreamSubscription<Map<dynamic, dynamic>> _batteryStateSubscription;
  final TextEditingController controller = TextEditingController();
  bool imageFound = false;

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

    _batteryStateSubscription =
        _battery.onBatteryStateChanged.listen((Map<dynamic, dynamic> state) {
          setState(() {
            _batteryState = 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(() {
      print("Test::${controller.text}");
    });
  }

  Future<void> initPlatformState(int type) async {
    String platformVersion_ = "";

    if (type == 3) {
      String descriptionData = await _battery.checkPermission("Android");
      print("return:$descriptionData");
    }
    if (type == 100) {
      String descriptionData = await _battery.startScanChiperLab();
      print("return:$descriptionData");
    } else if (type == 200) {
      String descriptionData = await _battery.stopScanChiperLab();
      print("return:$descriptionData");
    } else if (type == 201) {
      String descriptionData = await _battery.pickFileFromGallary(
          Platform.isAndroid ? "android" : "IOS", "1");
      print("return:$descriptionData");
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion_;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('ECP Plugin Sync'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('Running on: $_platformVersion\n'),
              Text('Progress on: ${_batteryState.toString()}\n'),
              const SizedBox(height: 20),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  ElevatedButton(
                    onPressed: () => initPlatformState(3),
                    child: const Text('Check Permission'),
                  ),
                  ElevatedButton(
                    onPressed: () => initPlatformState(100),
                    child: const Text('Start Scan'),
                  ),
                ],
              ),
              const SizedBox(height: 10),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  ElevatedButton(
                    onPressed: () => initPlatformState(200),
                    child: const Text('Stop Scan'),
                  ),
                  ElevatedButton(
                    onPressed: () => initPlatformState(201),
                    child: const Text('Pick File'),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    _batteryStateSubscription.cancel();
    controller.dispose();
    super.dispose();
  }
}
3
likes
140
points
936
downloads

Publisher

unverified uploader

Weekly Downloads

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

Documentation

API reference

License

MIT (license)

Dependencies

flutter, json_annotation, json_serializable, plugin_platform_interface

More

Packages that depend on ecp_sync_plugin