getLibraryDirectory not working for desktop app

Issue

i’m working on Flutter desktop application and got stuck at a point. I want to create local database for data storage. I’m using path_provider plugin to get path of directory for saving database file. the function getLibraryDirectory() not working in my application. I debug my application also at the point of creation of database this function throw exception "UnimplementedError: getLibraryPath() has not been implemented".

This is the plugin i am using. https://pub.dev/packages/path_provider

Anyone help me out there. Thanks

Solution

I’ve looked into the package’s sources and there is no implementation for the method getLibraryDirectory() on Windows and Linux as the property getLibraryPath() needed to call this method has not been implemented either. Based on the source getLibraryDirectory() seems implemented on MacOS only.

Here are the methods that should be implemented for Windows and Linux:

  • getTemporaryDirectory()
  • getApplicationSupportDirectory()
  • getApplicationDocumentsDirectory()
  • getDownloadsDirectory()

And one more for Windows only:

  • getPath(String folderID) // Retrieve any known folder from Windows.

Answered By – Guillaume Roux

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *