'Runtime error in production causing a black screen

According to this, a grey screen will appear when a Flutter app crashes due to a runtime error if the app is in release mode, and a red screen if in debug mode.

My app is showing a grey in MOST runtime errors, for example:

List<int> myList =[1,2,3];
int a = myList[5]

This will cause a

List index out of range.

Which is showing a grey screen in my device and the tester mentioned below.

But in one of my tester devices (Samsung s20) this black screen appeared.

Null safety error

Even if the app is deleted from cache and a newer version is installed, the app will open in this image with the same error.

My app isn't connected to any crash report services and the tester forgot how he had the error and in which page.

I'm now blind. Any suggestions on how to debug this? I've tried everything and the user also tried to get the error for a second time but we couldn't.

And why didn't this show a grey screen?



Solution 1:[1]

try to avoid this type of run time error with some conditions like if if your list has some data and you directly use any of index try to check first that if any data exist on that list or not like this:-

List<int> myList =[1,2,3];
if(myList[5] != null){
  int a = myList[5];
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dipak Ramoliya