Issue
I want to convert an XFile to File to upload the file to Firebase since Firebase only uploads in File format. The code is as follows:
XFile videofile;
videofile = file;
await FirebaseStorage.instance.ref(imageRef).putFile(videoFile);
Gives an error saying XFile can't be uploaded to Firebase
Using XFile package from XFile package gives another error saying:
The name 'XFile' is defined in the libraries 'package:cross_file/src/types/interface.dart' and 'package:xfile/src/xfile_core.dart (via package:xfile/xfile.dart)'. Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.
other dependencies in the file are
import 'dart:async';
import 'dart:io';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
Solution
File file = File(videofile.path);
.toFile() may not work because XFile plugin may conflict with another plugins
Answered By - yasar can clngr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.