Writing code for multiple screen sizes

Hello all, I’m new to programming in general. I’ve been working on a project in flutter for the last couple of months and I’m wondering what’s the best practice for responsive design.

I know you can use media queries, the expanded widget, etc but which is best?
I have a few screens that if I don’t add a media query, on a smaller screen I get a bottom overflow error.

To solve this problem I wrote the following code:

final _height = MediaQuery.of(context).size.height;
SizedBox(height: _height <600? _height * .01: _height *.08 )

I’m afraid though that if the height of the screen doesn’t fit within that height parameter I will get an overflow error and I can’t test every single screen size.

I’ve been going around in circles for the last few days. Any help would be greatly appreciated!!