As I said, this question is very simple
If you have this question, you can refer to this link and use the official documents
But if you are looking for the answer to this question in StackOverflow, the answer is:
http.head(Uri.parse(myUrl)).then(
(response) {
if (response.statusCode == 200) {
print(response.headers['content-type']);
}
},
);
edit:
Thanks to jamesdlin
Given that content-type is a value reported from the server, it is not reliable.
An alternative and more reliable way is to use package:mime and the lookupMimeType function. like this:
http.get(Uri.parse(myUrl)).then(
(response) {
if (response.statusCode == 200) {
final data = response.bodyBytes;
final mime = lookupMimeType('', headerBytes: data);
print(mime); // Print type of data
}
},
);