Home > Software engineering >  Flutter - Stream Builder does not show any content in release apk, but works fine in debug apk
Flutter - Stream Builder does not show any content in release apk, but works fine in debug apk

Time:02-26

I am new to flutter. I have built the app using flutter and firestore. I am fetching the list of data using stream builder. Inside Stream builder, I have used ListView.builder() to showcase the content.

The problem is everything works fine in debug apk, but in release apk or app bundle ListView shows no content. its and empty scrollable content.

I have successfully signed the apk as well. I tried this since I felt signed apk might be an issue. but still, the results are the same.

CodePudding user response:

These are the possible issues that comes when the app is in release mode and still gives grey screen.

1- Ensure firebase and flutter binding is Initialized in main. Ignore the firebase code if you aren't using firebase. You need to add async to your main like the example below and then other part of the code where you return runApp

void main() async {
    WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();
}

2- Check if internet permission is given to app or not. It gives grey screen error if internet permission is not given in AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>

3- If you run the app in debug mode then if there is any error coming in debugger or terminal then you have to resolve that. Its quite common to make a mistake with ListView builders like if you wrap it with some Containers and expanded or with stack etc it may work in debug but in release it won't.

To avoid issues like described in number 3 run the app in --release mode because the release mode catches such errors which are supposed to come on real device after releasing the app

flutter run --release 
  • Related