Search code examples
flutterdio

get file location when using dio get file


I'm trying to download an sqlite file from my website so my Flutter app uses it within the application.

I need to know how to get the path of the downloaded file. Where are they stored? How do I get a handler or path string to where that sqlfile is?

Here's the code.

try {
  Response response = await Dio().get("https://mysqliteFile.sqlite");
  print('response is' + response.toString());

} catch (e) {
  print(e);
}

// Construct a file path to copy database to
Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, DBassistanceClass.databaseName);

thanks


Solution

  • Use download method to save the file in a specific path

    await dio.download("https://mysqliteFile.sqlite", path);