Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grey screen Errors in Release Mode #3103

Open
fluttyCat opened this issue May 17, 2024 · 9 comments
Open

Grey screen Errors in Release Mode #3103

fluttyCat opened this issue May 17, 2024 · 9 comments
Assignees

Comments

@fluttyCat
Copy link

When I build the app with my laptop, something strange happens
When I switch between the app pages, the error "Controller not found" appears randomly
and the error says it is OBX widget that causing this.either loses the controller or does not register it at all when navigating between pages. but in other laptops everything is fine and the APK works correctly.

class Detail extends GetView {
Detail({Key? key}) : super(key: key);

@OverRide
Widget build(BuildContext context) {

final textTheme = Theme.of(context).textTheme;
return AppScaffold(
  preferredSize: PreferredSize(
    preferredSize: Size.fromHeight(60),
    child: SafeArea(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          SizedBox(
            width: 15,
          ),
          Expanded(
            child: Align(
              alignment: Alignment.centerLeft,
              child: IconButton(
                  onPressed: () {
                    Navigator.pop(context);
                  },
                  icon: SvgPicture.asset("assets/svgIcons/backarrow.svg")),
            ),
          ),
          Expanded(
              child: Center(
            child: Text(
              "Detail",
              textAlign: TextAlign.center,
              style: textTheme.headline4!
                  .copyWith(color: lightColorPalette.greySwatch.shade900),
            ),
          )),
          Expanded(child: Container()),
          SizedBox(
            width: 30,
          ),
        ],
      ),
    ),
  ),
  child: Obx(() => Container(
        height: Get.height,
        child: SingleChildScrollView(
          child: Stack(
            children: [
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 24),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                       
                  ....
                      ],
                    ).paddingOnly(top: 16, bottom: 20),

                
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        ...
                        ...
                        ...

                          ],
                        ),
                      ],
                    ).paddingOnly(bottom: 12),

                    Container(
                        height: 66,
                        decoration: BoxDecoration(
                            color: Color.fromRGBO(245, 246, 248, 1),
                            borderRadius:
                                BorderRadius.all(Radius.circular(8))),
                        child: Padding(
                          padding: EdgeInsets.only(
                              right: 15, left: 16, top: 8, bottom: 8),
                          child: Row(
                            children: [
                              ...
                              ...
                              ...
                              ...
                              ...
                  ],
                ),
              ),
              Visibility(
                  visible: controller.showLoader.value,
                  child: Container(
                    height: Get.height,
                    child: AppLoadingWidget(),
                  ))
            ],
          ),
        ),
      )),
);

}
}

To Reproduce
Steps to reproduce the behavior:

  1. open the app
  2. navigate into one of the items in home page
    3.grey screen

Expected behavior
I Expect not seeing grey screen

Screenshots
photo_2024-05-17 17 20 01

Flutter Version:
Flutter (Channel [user-branch], 3.13.7

Getx Version:
get: ^4.6.1

Describe on which device you found the bug:
samsung galaxy A21

@KyawSoeW1n
Copy link

You need to check how to create controller. You will have some scenario for that error. Please check the scenario.

@fluttyCat
Copy link
Author

how should I create the controller?????

@deepss1
Copy link

deepss1 commented May 20, 2024

I would suggest you to check the counter app with GetX

https://pub.dev/packages/get#counter-app-with-getx

@KyawSoeW1n
Copy link

@fluttyCat You can create controller like Get.lazyOut(()=> TestController) or Get.put(TestController);
In release mode, flutter show grey screen if app got error. You need to check where the controller is created.
Trace the problem and check the controller is registered or not. You will find the solution.

@fluttyCat
Copy link
Author

fluttyCat commented May 20, 2024

I do it this way, I think you did not understand my problem. just in my laptop this error happens, when build apk. but with another systems when they get the apk, it is ok
@deepss1 @KyawSoeW1n @jonataslaw

@allasca
Copy link

allasca commented May 20, 2024

if you are @fluttyCat using getview then

class Detail extends GetView<MyControllerName> {

@fluttyCat
Copy link
Author

@allasca I do it exactly like this
creating controller is not the issue.
just in my laptop this error happens, when build apk. but with another systems when they get the apk, it is ok

@allasca
Copy link

allasca commented May 25, 2024

check your main.dart, use like this. then you can get.find everywhere. @fluttyCat

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: MainController(),
        builder: (_) {
          return GetMaterialApp(
            title: "Lestaripedia",
            theme: ThemeData(
              colorScheme: ColorScheme.fromSeed(
                seedColor: Colors.green,
                brightness: Brightness.light,
              ),
              useMaterial3: true,
            ),
            darkTheme: ThemeData(
              colorScheme: ColorScheme.fromSeed(
                seedColor: Colors.green,
                brightness: Brightness.dark,
              ),
              useMaterial3: true,
            ),
            themeMode: _.isDarkMode.value ? ThemeMode.dark : ThemeMode.light,
            home: const LoginUi(),
          );
        });
  }
}

@fluttyCat
Copy link
Author

@allasca main.dart is not stateles. it is just a function
I cannot change it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants