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

Not Giving Any Size(width or Hight) When Android Released App Until First Screen Refresh #33

Open
Sameera-Perera opened this issue Oct 27, 2021 · 4 comments

Comments

@Sameera-Perera
Copy link

Min APK - 16 and 21(i tried both)
In debug mode its works perfectly. But after the app is released to android, it won't work on the first screen until refresh. I tried even with fresh flutter app result is the same.

** in my example second container MediaQuery.of(context).size.height work perfectly in first screen.

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Sizer(
      builder: (context, orientation, deviceType) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const HomeScreen(),
        );
      },
    );
  }
}
class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              height: 10.h,
              width: 10.w,
              color: Colors.grey,
            ),
            Container(
              height: MediaQuery.of(context).size.height/10,
              width: MediaQuery.of(context).size.width/10,
              color: Colors.amber,
            )
          ],
        ),
      ),
    );
  }
}
@samerjallad
Copy link

I faced the same issue recently with my App, in debugging it is working properly but after release I need to do refresh to the app, sometimes optimizing my phone then it might work, yesterday I removed all the the .h & .w from the main screen & replace them with int Numbers & the app was working in a good way except the fonts since i was was using .sp for the font size... also the strange thing is the same is affecting the main screen only, other screens are working in a good way.
this is what happened:
WhatsApp Image 2021-10-28 at 9 18 04 PM
and this is the original screen.
WhatsApp Image 2021-10-28 at 9 18 03 PM

@samerjallad
Copy link

i was doing another try for the package because I really like using it... so I remembered during coding if you add a const modifier to the container, font, sizedBox...etc.... it will give an error.. so what I did in the main page I removed const modifier from the main.dart which will open the main screen & now it is working as it should be... i will keep testing it to make sure that it is OK.... my old code was
return Sizer( builder: (context, orientation, deviceType) { return const MaterialApp( home: MainScreenPage(), ); }, );
and my new code is:
return Sizer( builder: (context, orientation, deviceType) { return MaterialApp( home: MainScreenPage(), ); }, );

@Sameera-Perera
Copy link
Author

Thank you samerjallad for your support. I think I should try it.
I also found a solution. I added a splash screen for 1 second. I worked too.

@kaustuv-praz
Copy link

Use responsive_sizer package.
This package is not maintained any more.
responsive_sizer package is a branch of this one with active development.
Issue is solved there.
https://pub.dev/packages/responsive_sizer

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

3 participants