Home > Blockchain >  Flutter: How to add assets to debug build only?
Flutter: How to add assets to debug build only?

Time:08-30

In Flutter, is there a way to add assets for debug builds only? Or to strip them from release builds?

The idea is to generate the play- and app-store screenshots from inside the app. Those screenshots are composed of various images that are otherwise unused and hence shouldn't be included in the release build. Question is, can those assets somehow be removed from release builds?

As an alternative, would it be possible to load the images from the Flutter project directory while the app is running in debug mode? -or at the emulator?

Could the test folder, perhaps, be abused for it?

How would you approach that requirement?

Any advise is welcome, Thank you.

CodePudding user response:

Use git, and create a branch for debug mode, and commit your files only in debug branch, when you need release your app, checkout to other branch like main or release, and your asset files not include in your release

CodePudding user response:

you can use KDebugMode from dart foundation like

if(KDebugMode){
    //your code
}

or

KDebugMode ? //your code : //do something else
  • Related