mirror_connect

A lightweight Flutter SDK that connects your app to the Magic Mirror real-time infrastructure

Description

This SDK provides a simple and consistent way to establish and manage connections, enabling seamless live data sync, instant updates, and event-based communication between your app and the Magic Mirror platform.

Examples

Stap 1: Initialize the SDK

// Initialize the SDK
 MagicConnect.init();

Stap 2: Configuration in initState

  @override
  void initState() {
    super.initState();
    sessionId = getSessionId();
    connectToServer();
  }
};

QR Code data

 Map<String, String> qrData  = {
      "urlPrefix": "xx_xx",//add url prefix provide by plushvie
      "customerId": "xx_xx_xx",// add customer id provide by plushvie
      "userName": "Avishkar", //add customer name
      "userNumber": "9876543210", //add customer number
      "employeeId":"12",//add JC's name or employee Id
      "branch": "Jhodhpur",//Add store branch name here
      "city": "Ahmedabad",//Add store city name
      "sessionId": sessionId,//here use you session id
      "counterNumber": "1" // number of counter to be used,
    };

Send product data

  sentData(String product){

    var productData = {
      "sessionId": sessionId,
      "data": {
        "scannedItem": product,
        "itemType": "product",
        "timestamp": DateTime.now().toIso8601String(),
      }
    };
    MagicConnect.send("scannerData", productData);
  }

 TextButton(
              onPressed: (){
                  sentData(controller.text);
                },
              child: const Text("Disconnect"),
            )
 

Disconnect from magic mirror

  void disconnectConnection() {
    var disconnect = {
      "sessionId": sessionId,
      "data": {
        "scannedItem": "disconnect",
        "itemType": "try",
        "timestamp": DateTime.now().toIso8601String(),
      }
    };
    MagicConnect.send("scannerData", disconnect);
    MagicConnect.onDisconnect;
    setState(() {
      isConnected = false;
      productId.clear();
    });
  }
 TextButton(
              onPressed: disconnectConnection,
              child: const Text("Disconnect"),
            )

Plushvie

Version

Libraries

mirror_connect