How to get the url from Firebase Storage file?

You have to await for the URL when calling ref.getDownloadURL()

change

return ref.getDownloadURL();

into

return await ref.getDownloadURL();

The UploadTask class extends Future, so you can also use await there already:

await ref.putData(signature!);
final downurl = await ref.getDownloadURL();
final url = downurl.toString();