yxc_cast 0.0.2 copy "yxc_cast: ^0.0.2" to clipboard
yxc_cast: ^0.0.2 copied to clipboard

PlatformiOS

A new Flutter project.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:yxc_cast/yxc_cast.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    YxcCast.authLeBo("20", "a20b4b19e6da15f95464af0e4aa59564");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              TextButton(
                onPressed: () {
                  try {
                    YxcCast.cast();
                  } on PlatformException {
                    print("调用 cast 方法异常");
                  }
                },
                child: Text("投屏"),
              ),
              TextButton(
                onPressed: () {
                  try {
                    YxcCast.devices.then((value) {
                      print("搜索到设备:${value.length}");
                      for (int i = 0; i < value.length; i++) {
                        Object? object = value[i];
                        Map<Object?, Object?> devices = object as Map<Object?, Object?>;
                        String lelinkServiceName = devices["lelinkServiceName"] as String;
                        if (lelinkServiceName == "星宸") {
                          try {
                            YxcCast.connectionDevice(devices);
                          } on PlatformException {
                            print("调用 connectionDevice 方法异常");
                          }
                          return;
                        }
                      }
                    });
                  } on PlatformException {
                    print("调用 devices 方法异常");
                  }
                },
                child: Text("搜索设备列表"),
              ),
              TextButton(onPressed: () {
                try {
                  YxcCast.playMusic();
                } on PlatformException {
                  print("调用 playMusic 失败");
                }
              }, child: Text("播放音乐")),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter project.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on yxc_cast

Packages that implement yxc_cast