multipartFile property

Future<MultipartFile> get multipartFile
  • this will be used for get a posting image
  • needs a key name for posting or key must be empty

Implementation

Future<MultipartFile> get multipartFile async {
  return _file == null
  ? throw Exception()
  : kIsWeb
    ? MultipartFile.fromBytes(
      _imageKey,
      _file!.bytes!,
      filename    : '$_imageKey.$_extension',
      contentType : MediaType(_imageKey, _extension)
    )
    : await MultipartFile.fromPath(
      _imageKey,
      _file!.path!,
      contentType: MediaType(_imageKey, _extension)
    );
}