import 'dart:io';

import 'package:flutter/services.dart';

class ScreenStreamPlugin {
  static const _channel = MethodChannel("screen_stream");

  static Future<bool> start(String url) async {
    try {
      await _channel.invokeMethod("start", {"url": url});
      return true;
    } catch (e) {
      return false;
    }
  }

  static Future<bool> stop() async {
    try {
      await _channel.invokeMethod("stop", []);
      return true;
    } catch (e) {
      return false;
    }
  }

  static Future<bool> checkPermission() async {
    if (Platform.isAndroid) {
      try {
        bool success = await _channel.invokeMethod("checkPermission", []);
        return success;
      } catch (e) {
        return false;
      }
    } else {
      return true;
    }
  }

  static Future<bool> requestPermission() async {
    if (Platform.isAndroid) {
      try {
        bool success = await _channel.invokeMethod("requestPermission", []);
        return success;
      } catch (e) {
        return false;
      }
    } else {
      return true;
    }
  }
}
