Filip
Filip

Reputation: 2411

How to check file type?

I have code like this and I want to know what type of file I get. png or jpg. How to do this?

var image;
File _image;
image = await ImagePicker.pickImage(source: source);
setState(() {
     _image = image;
});

Upvotes: 0

Views: 749

Answers (1)

null
null

Reputation: 573

I only thought of this solution, intercepting the path string.

List<String> imagePathArr = _image.path.split(".");

print("image's type  =  ${imagePathArr[1]}");

Upvotes: 1

Related Questions