0

I have developed (on a Mac) a small Flutter app to learn the technology. Now, I would like to build it and use it on Mac, Linux and Android. The few packages I have used claim compatibility with all systems.

So the first thing I did was to run flutter build macos. I indeed obtain an application under build/macos/Build/Products/Release/nameofmyapp.app. It seems this runs correctly, but it fails, for instance, loading data from a DB, which is the first thing it should do.

I have a few questions:

  • are there any other steps that I should take? I see a long guide about the release process, but to be frank I don't need or want any of that: I only want to use the app myself. Is there something else to do other than flutter build macos?
  • am I looking for the built app in the right place?
  • if I did everything correctly, could it be that I need to authorize the app to access to the file in some way? Should I manage this workflow myself, or is there a standard way to perform this action in Flutter?

Sorry for asking more than one question, but I am not sure whether what I am doing wrong is

  • the build process
  • where to look for the built app, or
  • (not) handling the app permissions.

EDIT

Following a suggestion by Madhavam, I tried flutter run --release. The result is identical to running the built application: nothing is loaded from the database, and no errors appear in the console.

To be clear, these are the libraries that are not working:

  • sqflite should load data from a database (in my Documents folder) but does not show anything
  • file picker cross should allow me to load data from a JSON file, but when I try this interaction, I an not shown any dialog to load a file
  • shared preferences should read some settings, but they all appear as null

In short, anything that has to do with interacting with external files or storage does not seem to work

Andrea
  • 20,253
  • 23
  • 114
  • 183

2 Answers2

1

Yup, you have to manage it yourself. Take a look at this package :https://pub.dev/packages/permission_handler

If you're using Firebase then you probably need to add the release keys.

One thing too, if you face an error only in the release build then I recommend running the app with flutter run --release so that you can see the errors that are being thrown.

Madhavam Shahi
  • 1,166
  • 6
  • 17
  • Thank you. Following your suggestion, I tried running it in release mode, but I did not see any error. I am editing my question to add this piece of information – Andrea Aug 19 '21 at 08:14
  • Oh, well i'm glad you were able to make it work later. Happy Coding! – Madhavam Shahi Aug 20 '21 at 17:18
1

So it seems that this is related to the default being an app that runs in sandbox. Since I do not want to distribute the app, it was fine for me to disable this setting. Details are in this answer

Andrea
  • 20,253
  • 23
  • 114
  • 183