shahidpharm
shahidpharm

Reputation: 25

Flutter app shows grey box in mobile or release mode but ok in emulator

I am facing problem. My app is working in emulator well but in release mode or in mobile device it is showing grey box for the below code. I am using Getx package. Cannot figure out.

Please help.

Positioned(
              bottom: 0,
              child: Obx(() {
                if (appBarController.isDataProcessing.value == false) {
                  if (appBarController.loggedUserData[0] != null) {
                    return GestureDetector(
                      onTap: () {
                        // print('id');
                        appBarController.getAlumniProfile(
                            appBarController.loggedUserData[0]['id']);
                      },
                      child: Hero(
                        tag: appBarController.loggedUserData[0]['id'].toString(),
                        child: appBarController.loggedUserData[0]['user_image'] !=
                                null
                            ? Container(
                                height: 50,
                                width: 50,
                                decoration: BoxDecoration(
                                  border: Border.all(width: 0.5),
                                  shape: BoxShape.circle,
                                  image: DecorationImage(
                                    fit: BoxFit.cover,
                                    image: NetworkImage(
                                      appBarController.loggedUserData[0]
                                          ['user_image'],
                                    ),
                                  ),
                                ),
                              )
                            : Container(
                                decoration: BoxDecoration(
                                  border:
                                      Border.all(width: 0.5, color: Colors.white),
                                  shape: BoxShape.circle,
                                ),
                                child: Icon(
                                  Icons.person,
                                  size: 30,
                                  color: Colors.white,
                                ),
                              ),
                      ),
                    );
                  } else {
                    return Center(
                      child: SizedBox(),
                    );
                  }
                } else {
                  return Center(
                    child: CircularProgressIndicator(),
                  );
                }
              }),
            )

Thanks

This is the screenshot of my problem.

Updated code(Working Code)

Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Obx(() {
                    if (appBarController.isDataProcessing.value == false) {
                      if (appBarController.loggedUserData[0] != null) {
                        return GestureDetector(
                          onTap: () {
                            // print('id');
                            appBarController.getAlumniProfile(
                                appBarController.loggedUserData[0]['id']);
                          },
                          child: Hero(
                            tag: appBarController.loggedUserData[0]['id']
                                .toString(),
                            child: appBarController.loggedUserData[0]
                                        ['user_image'] !=
                                    null
                                ? Container(
                                    height: 50,
                                    width: 50,
                                    decoration: BoxDecoration(
                                      border: Border.all(width: 0.5),
                                      shape: BoxShape.circle,
                                      image: DecorationImage(
                                        fit: BoxFit.cover,
                                        image: NetworkImage(
                                          appBarController.loggedUserData[0]
                                              ['user_image'],
                                        ),
                                      ),
                                    ),
                                  )
                                : Container(
                                    decoration: BoxDecoration(
                                      border: Border.all(
                                          width: 0.5, color: Colors.white),
                                      shape: BoxShape.circle,
                                    ),
                                    child: Icon(
                                      Icons.person,
                                      size: 30,
                                      color: Colors.white,
                                    ),
                                  ),
                          ),
                        );
                      } else {
                        return Center(
                          child: SizedBox(),
                        );
                      }
                    } else {
                      return Center(
                        child: CircularProgressIndicator(),
                      );
                    }
                  }),

                  IconButton(
                    onPressed: () {
                      logout();
                    },
                    icon: Icon(Icons.exit_to_app),
                    tooltip: 'Log out',
                    color: Colors.white,
                    iconSize: 30,
                  ),
                  // Text(appBarController.loggedUserData[0]['id'].toString()),
                ],
              )

I have learned to solve the problem. This is pleaure to me. Thanks

Upvotes: 1

Views: 1662

Answers (1)

Diwyansh
Diwyansh

Reputation: 3514

Basically grey box in release mode refers to an error if the same error occurs in debug mode then it would show you a red screen. But as you said this error not showing in debug mode then you have an other option to find the causing section by running your app in profile mode. There are some kind of error that debug mode ignores but it will reflect in profile mode.

Upvotes: 1

Related Questions