Skip to content Skip to sidebar Skip to footer

Flutter Release Apk Is Not Working But Debug Apk Is Working

My debug APK is working fine but release APK is not working after building it from the command flutter build apk. What can be the real issue here?

Solution 1:

In debug mode, any global variables or methods will work perfectly but in case of release mode, only native code is compiled. So let's assume we are getting some unformatted text and we want to format it and return so if you have a global function to format text like below it will work fine in debug mode but might cause problems in release mode.

Code with global function.

// Global FunctionStringformatText(String unformattedText){
    // ....return formattedText;
}

Widget_showFormattedText(String unformattedText) {
   final fd = formatText(unformattedText);
   returnText(fd);
}

Instead of this we should follow best practices and wrap everything inside a class which is present globally.

// Code with class method.classCustomFunctions{
  staticStringformatText(String unformattedText){
      // ....return formattedText;
  }
}

Widget_showFormattedText(String unformattedText) {
   final fd = CustomFunctions.formatText(unformattedText);
   returnText(fd);
}

Post a Comment for "Flutter Release Apk Is Not Working But Debug Apk Is Working"