import 'package:flutter/services.dart';

class SAFPlugin {
  static const platform = const MethodChannel('com.perol.dev/saf');

  static Future<String?> createFile(String name, String type) async {
    final result = await platform
        .invokeMethod("createFile", {'name': name, 'mimeType': type});
    if (result != null) {
      return result;
    }
    return null;
  }

  static Future<void> writeUri(String uri, Uint8List data) async {
    return platform.invokeMethod("writeUri", {'uri': uri, 'data': data});
  }

  static Future<Uint8List?> openFile() async {
    return platform
        .invokeMethod<Uint8List>("openFile", {'type': "application/json"});
  }
}
