origo_sdk 0.1.2 copy "origo_sdk: ^0.1.2" to clipboard
origo_sdk: ^0.1.2 copied to clipboard

Flutter plugin for Origo SDK integration, providing mobile key functionality for access control systems including endpoint setup, reader scanning, and lock management.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:origo_sdk/origo_sdk.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  bool _isInitialized = false;
  final _origoSdkPlugin = OrigoSdk();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    bool isInitialized = false;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      isInitialized = await _origoSdkPlugin.initialize(
        '2',
        'HID-FAIRPRICEGROUP-MYAPPFORFAIRMLYUAT',
        'HID-FairpriceGroup-MyAppForFairmilyUAT-2.0',
      );
    } on PlatformException {
      isInitialized = false;
    }

    // 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 (!mounted) return;

    setState(() {
      _isInitialized = isInitialized;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Container(
        width: double.infinity,
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const SizedBox(height: 20),
            Text('SDK Initialized: $_isInitialized\n'),
            TextButton(
                onPressed: () async {
                  final response = await _origoSdkPlugin.applicationStartup();
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(response)),
                  );
                },
                child: Text('Application Startup')),
            TextButton(
                onPressed: () async {
                  final response = await _origoSdkPlugin.getEndpointSetupStatus();
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(response)),
                  );
                },
                child: Text('Get Endpoint Setup Status')),
            TextButton(
                onPressed: () async {
                  final response =
                      await _origoSdkPlugin.endpointSetup('BARN-ACQS-RG3M-72FM');
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(response)),
                  );
                },
                child: Text('Endpoint Setup')),
            TextButton(
                onPressed: () async {
                  final response = await _origoSdkPlugin.endpointUpdate();
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(response)),
                  );
                },
                child: Text('Endpoint Update')),
            TextButton(
                onPressed: () async {
                  final response = await _origoSdkPlugin.startScan();
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(response)),
                  );
                },
                child: Text('Start Scan')),
            TextButton(
                onPressed: () async {
                  final response = await _origoSdkPlugin.stopScan();
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(response)),
                  );
                },
                child: Text('Stop Scan')),
          ],
        ),
      ),
    );
  }
}
1
likes
125
points
40
downloads

Publisher

verified publisherwhitecloak.com

Weekly Downloads

Flutter plugin for Origo SDK integration, providing mobile key functionality for access control systems including endpoint setup, reader scanning, and lock management.

Topics

#bluetooth #security #locks #origo

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on origo_sdk

Packages that implement origo_sdk