How to download a file from a webpage on Flutter App?

90 Views Asked by At

I am developing an app that directs the user to a webpage using a button. It opens the URL correctly, but this website has many pdf files that can de downloaded. The problem is, when I press the file, nothing happens. And I have tested this URL outside the app (regular old internet app), and it works just fine. The problem is, when i try to dowload these files "inside" my app, it doesn't work. Is this a permission problem?

I have seen some people saying to use the full URL with the file already (https://example/file.pdf), but as I said, there are multiple files to download, so this isn't a solution for me. One possible solution would be to use flutter_inappwebview according to ChatGPT (LOL), but i have never used this package before.

Any help would be appreciated. I didn't find anything online.

Here is my code that directs the user to the webpage:

Column(children: [
  FloatingActionButton.large(
  backgroundColor: Color.fromRGBO(136, 221, 198, 1),
  onPressed: () {
  launchUrl(Uri.parse( 'https://www.agricultura.rs.gov.br/agrometeorologia'));
   },
  child: Image(
  image: AssetImage("assets/book.png"),
  height: size.height * .1,
  )),
  SizedBox(height: screenHeight * .02),
  Text(
  'Leitura \nComplementar',
   textAlign: TextAlign.center,
  style: TextStyle(
  fontWeight: FontWeight.w700,
  fontSize: 15,
  color: Colors.black),
  )
 ])
0

There are 0 best solutions below