Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

need to calculate screen height and bottom nav to get responsive margin but im not good at math

i have screen height 844 and bottom kBottomNavigationBarHeight 87 and before bottomNav i have a button which i want to give a margin between the button and bottomNav to look like this

enter image description here

i want the margin to be responsive so in every device it will look like the image above, so i have a logic to get the margin height by calculating screen height and kBottomNavigationBarHeight but i don’t know how to calculate it or is there someway to achieve this better ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

what i’ve tried

 EdgeInsets.only(top: Get.height / kBottomNavigationBarHeight)

this is for full image of the screen

enter image description here

>Solution :

I haven’t seen your full code but,

I assume you use Column to show all the widgets (since it overflows).
Maybe your code looks like this:

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

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        UpperPart(),
        MovieTitle(),
        MovieStats(),
        MovieDescription(),
        RatingButton(),
        BottomNav(),
      ]
    );
  }
}

If you want to show the button over the bottom nav with the same height:

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

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        UpperPart(),
        MovieTitle(),
        MovieStats(),
        MovieDescription(),
        Spacer(), // fills the remaining space
        RatingButton(),
        SizedBox(height: 30), // Adjust this value to your specification. 
        BottomNav(),
      ]
    );
  }
}

But this may not solve the overflow problem.
Maybe moving the Uppersection (UpperPart to MoviewDescription) to a scrollable widget may be the solution

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

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Expanded(
          child: SingleChildScrollView(
            child: Column(
              children: [
                UpperPart(),
                MovieTitle(),
                MovieStats(),
                MovieDescription(),
              ]
            )
          ),
        ),
        RatingButton(),
        SizedBox(height: 30), // Adjust this value to your specification. 
        BottomNav(),
      ]
    );
  }
}

hope it helps!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading