Flutter: Download and open pdf (or any file)

1.2k Views Asked by At

I have been using Flutter, and recently migrated to the latest stable version of 3.13.2.

I have a form screen which takes a certain number of field inputs and prepares a request to the server. The server in turn sends a response with a link to a pdf. I would like to download this file so it is present for user to open at a latter point from her/his "Files" app (I am doing this for Android and iOS).

Previously, we had been using flutter_downloader package to get this job done. The latest policy changes by Google Play have announced that they require that all apps must target a sdk of at least API level 33. The flutter_downloader package does not support API 33 yet, and fails to download the file in newer Android versions.

Given its state at the moment, and a lot of discussion within the community in its Issues tab, we are not sure when we can expect a fix for this.


An alternative to the above package was suggested which is background_downloader.

I have been trying my hands at this alternative, but I am facing too many complications migrating to it. There's some unstable behavior with this, a major of which is related to how streams are implemented in the package's example implementations. I get the impression that the creator of this package is too keen on closing off issues in Github, before a proper conclusion has been reached. So we are not sure if this would be a good choice for a long run.


Some of my colleagues in other projects make use of the Dio package to download files to user devices. We don't use dio in our application for network implementations, and it sounds a bit of an overkill to have this dependency simply for download purposes. If nothing else works out, I'll probably be resorting to this option too, though.


How is the rest of the Flutter community dealing with a download and open file problem for Android and iOS?

1

There are 1 best solutions below

1
Chinmay Nanaware On

Have you tried flutter_file_downloader? Works for me!