file_document_saver_method_channel.dart 803 Bytes
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'file_document_saver_platform_interface.dart';

/// An implementation of [FileDocumentSaverPlatform] that uses method channels.
class MethodChannelFileDocumentSaver extends FileDocumentSaverPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('file_document_saver');

  @override
  Future<String?> getPlatformVersion() async {
    final version =
        await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<bool> saveFile({required String path}) async {
    bool? result = await methodChannel.invokeMethod<bool>('saveFile', path);
    return result?? false;
  }
}