selectVideoFile method

Future<File?> selectVideoFile()

Implementation

Future<File?> selectVideoFile() async {
  var result = await FilePicker.platform.pickFiles(
    allowMultiple: false,
    type: FileType.custom,
    allowedExtensions: [
      'mp4',
      'm4v',
      'mov',
      'm4a',
      '3gp',
      '3g2',
      'mkv',
      'avi',
      'webm',
    ],
  );

  if (result != null) {
    File? file = File(result.files.single.path!);
    // log('video gotten');
    if (file.lengthSync() < 50000000) {
      return file;
    } else {
      return null;
    }
  } else {
    // User canceled the picker
    return null;
  }
}