sizeFormPath static method

Future<SizeFormPathResponse> sizeFormPath({
  1. required String path,
})

Check File Size of any File paths selected file path (String). Example user/android.downlaod/MYPDF.pdf

Implementation

static Future<SizeFormPathResponse> sizeFormPath(
    {required String path}) async {
  final Map<String, dynamic> params = <String, dynamic>{'path': path};

  if (path == "") {
    sizeFormFilePathResponse.value.status = Status.error;
    sizeFormFilePathResponse.value.message = Status.errorMessage;
  } else {
    try {
      final String? response =
          await _channel.invokeMethod('sizeForLocalFilePath', params);

      if (response != "error") {
        sizeFormFilePathResponse.value.status = Status.success;
        sizeFormFilePathResponse.value.message = Status.successMessage;
        sizeFormFilePathResponse.value.response = response;
      } else {
        sizeFormFilePathResponse.value.status = Status.error;
        sizeFormFilePathResponse.value.message = Status.errorMessage;
      }
    } on Exception catch (exception) {
      sizeFormFilePathResponse.value.status = Status.error;
      sizeFormFilePathResponse.value.message = exception.toString();
    } catch (e) {
      sizeFormFilePathResponse.value.status = Status.error;
      sizeFormFilePathResponse.value.message = e.toString();
    }
  }

  return sizeFormFilePathResponse.value;
}