flutter_plugin_hpplay 0.4.1 copy "flutter_plugin_hpplay: ^0.4.1" to clipboard
flutter_plugin_hpplay: ^0.4.1 copied to clipboard

A new Flutter plugin.

example/lib/main.dart

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

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

import 'package:flutter/services.dart';
import 'package:flutter_plugin_hpplay/flutterpluginhpplay.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  static const EventChannel eventChannel =
  EventChannel("sample.flutter.io/test_event_channel"); //samples 实际使用可以
  @override
  void initState() {
    super.initState();
    eventChannel
        .receiveBroadcastStream()
        .listen(eventListener, onError: _onError);
    initPlatformState();
  }
  ///
  /// Function(函数名称): eventListener
  /// Description(描述): 监听回调 与native通信 监听传屏状态
  /// Calls(被本函数调用的函数清单):
  /// Called By(调用本函数的函数清单):
  /// Table Accessed(被访问的表):
  /// Table Updated(被修改的表):
  /// Outputs(对输出参数的说明):
  /// Return(函数返回值的说明):
  /// Others(其他说明):
  /// Input: //输入参数说明,包括每个参数的作用、取值说明及参数间关系。
  /// ------------------------------------------------------------
  ///
  void eventListener(dynamic event) {
//    ClassHoursDetailsPage.state = DLNAStateType.kConnect;
//    _showOverlay(true);
    if (event is String && event.isNotEmpty) {
      Map<String, dynamic> json = jsonDecode(event);
      int ack = json["ack"];

//      if (ack == 5) {
//        search = true;
//      } else {
//        search = false;
//      }
      if (mounted) setState(() {});

      //
//      ClassHoursDetailsPage.state = DLNAStateType.kConnect;
      print('----------------------------ack${json["ack"]}');
//      tipDeviceConnect = event;
//      setState(() {});
    } else if (event is Map) {
      print('----------------------------Map');
      var devicesJsonString = event['devices'];
      print('----------------------------Map${devicesJsonString}');
      if (mounted) setState(() {});
    }
  }

  void _onError(Object obj) {}
  // 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.
    try {
      print('-----------------------initHppaly');
      platformVersion = await Flutterpluginhpplay.initHpplay;
      platformVersion = await Flutterpluginhpplay.HpplayBrowse;
    } 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
20
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_plugin_hpplay