蔡旻袁
蔡旻袁

Reputation: 181

Flutter how to enter full screen mode

I use setEnabledSystemUIOverlays to hide status bar and virtual button bar.

But there are blanks on the top and bottom of the screen (as seen in the photo):

Screen Photo

Does anyone know how to solve it?

Here is my code:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  SystemChrome.setEnabledSystemUIOverlays([]);
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: "Test",
      home: new MyHomePage(title: "Test"),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(title),
      ),
      body: new Container(
        color: Colors.red,
      ),
    );
  }
}

Upvotes: 6

Views: 16208

Answers (4)

xyz
xyz

Reputation: 1

flutter 2.x:

  • still has this problem.
  • // resizeToAvoidBottomInset: false not work for me.

my solution:

  • Container.height = Get.height // set max height
  • Container.child.image.fit = BoxFit.fill // with this
  • this work for me, under flutter 2.2.0

example full screen page:

  • full code:

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';


import '../controllers/splash_controller.dart';

class SplashScreenView extends GetView<SplashController> {
  final SplashController c = Get.find();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        /// key! fix full screen
        height: Get.height,

        ///
        child: Lottie.asset(
          /// image file:
          AppConfig.splash1,

          /// key! fix full screen
          fit: BoxFit.fill,

          ///
          controller: c.animationController,
          frameRate: FrameRate(60),
          repeat: true,

          ///
          delegates: LottieDelegates(
            text: (initialText) => 'test',
          ),

          onLoaded: (composition) {
            c.animationController..duration = composition.duration;
          },
        ),
      ),

      /// not work
      // resizeToAvoidBottomInset: false,
      backgroundColor: Colors.white,
    );
  }
}

Upvotes: 0

Zoha Shobbar
Zoha Shobbar

Reputation: 528

this it work perfect for me:

  @override
  Widget build(BuildContext context) {

    // To make this screen full screen.
    // It will hide status bar and notch.
    SystemChrome.setEnabledSystemUIOverlays([]);

    // full screen image for splash screen.
    return Container(
            child: new Image.asset('assets/splash.png', fit: BoxFit.fill));
      }
    }

import this

import 'package:flutter/services.dart';

Upvotes: 7

djungdlt3583
djungdlt3583

Reputation: 71

set resizeToAvoidBottomPadding: false to Scaffold.

   return Scaffold(
      resizeToAvoidBottomPadding: false,
   );

Upvotes: 7

Ben Hagen
Ben Hagen

Reputation: 645

There seems to be an issue on Android. For some reason it does not recalculate the SafeArea.

Upvotes: 2

Related Questions