blsdk_plugin 0.0.6 copy "blsdk_plugin: ^0.0.6" to clipboard
blsdk_plugin: ^0.0.6 copied to clipboard

A new Flutter plugin.

example/lib/main.dart

import 'dart:convert';
import 'dart:io';
// import 'dart:js_util';

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

import 'package:flutter/services.dart';
import 'package:blsdk_plugin/blsdk_plugin.dart';
import 'dart:convert' as convert;
void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
    var sdkMap = {
      "local_timeout":3000,
      "remote_timeout":5000,
      "device_tcp_server":"device-heartbeat-chn-ee08f451.ibroadlink.com",
      "device_http_server":"device-gateway-chn-ee08f451.ibroadlink.com",
      "lid":"b9b2a71c4cd4cd80d645ad6c4798fc9a",
      "license":"ubKnHEzUzYDWRa1sR5j8mtl/BpDgFgWYt6B1WBxUENHGvNth7UFMZwtzfObR2sZGV5LUXwAAAACZOGp1CYPEB8qZyWfI85AAfU8dsGPaqrpUvmvocA5Kvd31AKxLOUwtLPP16OfdL7dl+uRLfkjIHag3SDZefGoNJY65hcuDhVwfr1KiwAgj6AAAAAA=",
      "channel_id":"1",
      "app_host":"https://app-service-chn-ee08f451.ibroadlink.com"
    };
    String jsonString = convert.jsonEncode(sdkMap);

    BlsdkPlugin.initBLSDK(jsonString);
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await BlsdkPlugin.platformVersion ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // 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(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}
1
likes
120
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on blsdk_plugin