5

I had an issue in full screen view on orientation landscape mode, the problem is only with some devices nokia, redmi and one plus in landscape mode in left side of screen not covered fully.attaching screen shot below

enter image description here

in left side that space was my mobile walpaper, widget not covering full screen. so how do i solve this ?

class TestPage extends StatefulWidget {
  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  bool isFullScreen = false;

  /* To Update Screen Resolution Normal */
  void updateResolutionNormal() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
  }

  /* To Update Screen Resolution LandscapeLeft,LandscapeRight */
  void updateResolutionLandscape() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
    ]);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Container(
        child: GestureDetector(
            onTap: () {
              setState(() {
                isFullScreen = !isFullScreen;
                if (isFullScreen) {
                  updateResolutionLandscape();
                } else {
                  updateResolutionNormal();
                }
              });
            },
            child: Center(child: Text("Hai"))),
      ),
    );
  }
}

Thanks in advance.

3
  • I just ran your code on my machine and built it into my Redmi Note 8, and it works fine. The entire screen is filled up when I clicked to switch to landscape mode. So I can't tell what the problem is.
    – Chichebe
    Commented Jun 8, 2020 at 9:35
  • @Chichebe thanks. i tested with Nokia 6.1plus and Redmi Note 7S not filled up entire screen .. and after that i tested with samsung j7 pro it was working.. so what will be the problem in nokia 6.1 and redmi note 7s am not getting.
    – Jai Techie
    Commented Jun 8, 2020 at 9:49
  • @JaiTechie Wrap the Scaffold with a SafeArea widget. Kindly, let me know if it works.
    – mlodhi
    Commented Aug 21, 2023 at 7:07

1 Answer 1

0

I have a solution that could work, try:

body: Container(
        /// Try adding a width and height to your container like so. I set the width and height to the full dimensions of the device
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        child: GestureDetector(
            onTap: () {
              setState(() {
                isFullScreen = !isFullScreen;
                if (isFullScreen) {
                  updateResolutionLandscape();
                } else {
                  updateResolutionNormal();
                }
              });
            },
            child: Center(child: Text("Hai"))),
      ),

Hope it works!

1
  • No luck, still same tried with above mediaQuery not filled screen. and also tried with _mediaQueryData = MediaQuery.of(context); screenWidthpx = _mediaQueryData.size.width * _mediaQueryData.devicePixelRatio; screenHeightpx = _mediaQueryData.size.height * _mediaQueryData.devicePixelRatio; screenWidth = _mediaQueryData.size.width; screenHeight = _mediaQueryData.size.height;
    – Jai Techie
    Commented Jun 8, 2020 at 10:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.