76

How can I make a flutter application fullscreen. I already found out how to hide the status bar Hide Android Status Bar On Flutter App. but I can't seem to find how to hide the android navigation bar.

Quick learner
  • 10,632
  • 4
  • 45
  • 55
Bobola
  • 935
  • 2
  • 8
  • 10
  • @FarshidABZ The link you provided is for the Android SDK - Bobola was clearly looking for a Flutter solution. – SilSur Jun 13 '19 at 08:21
  • The most up-to-date solution is to use [`setEnabledSystemUiMode`](https://stackoverflow.com/a/69326491/6618622) – CopsOnRoad Jan 15 '22 at 19:37

14 Answers14

133

It's exactly like for Android status bar.

Doing SystemChrome.setEnabledSystemUIOverlays([]) hides both the status bar and the navigation bar.

p/s : use this SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); to disable full screen mode.

Huy Tower
  • 7,769
  • 16
  • 61
  • 86
Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
  • 1
    I am having a problem. I want this behaviour on only one screen. In initState `SystemChrome.setEnabledSystemUIOverlays([])` does the job to hide status bar and navigation bar, but in onDispose `SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values)` doesn't bring them back. – Gurleen Sethi Oct 01 '18 at 06:32
  • 20
    Just for clarification: the `SystemChrome.setEnabledSystemUIOverlays([]);` has to be added inside the build method of the class, but before the 'return'. – Pablo Insua Dec 28 '18 at 17:48
  • @GurleenSethi have you tried this: `SystemChrome.restoreSystemUIOverlays()`? – Pedro Massango Jan 03 '19 at 11:47
  • 4
    This does not work! When a text field got focus, the virtual keyboard appears, together with the mobile phone status bar, after the user enter something into the text field and lost focus, the status bar is still there, which means that the app is now not in full screen. It is said in the documentation that after the text field lost focus, we can only call the SystemChrome.setEnabledSystemUIOverlays again AFTER 1 SECOND, but I've tens of Text Fields in my app, how should I make my app always in Full Screen Mode? – Kenneth Li Mar 12 '19 at 12:36
  • 17
    For someone who doesn't know, you have to import 'Service.dart' `import 'package:flutter/services.dart'; ` – meditat Jun 10 '19 at 12:57
  • @GurleenSethi `SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.bottom, SystemUiOverlay.top]);` works for me – frankenapps Sep 03 '19 at 08:01
  • The top bar is still there but without text. Why? – Maseed Jul 18 '20 at 17:53
  • for some reason it leaves a black blank space where the status bar was ( when I try to do a full screen,) – Lidor Eliyahu Shelef Aug 27 '20 at 21:11
  • 1
    This is now deprecated! Can someone tell me the alternatives? – Balaji Sep 15 '21 at 06:45
  • 1
    @Balaji Check out SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive); Not very sure about which mode we need to use though – Ajay Oct 19 '21 at 07:02
  • 1
    `setEnabledSystemUIOverlays` is now deprecated and replaced by `setEnabledSystemUIMode` – Lucas Aschenbach Apr 07 '22 at 09:39
  • Can you help me with webview. I am playing video in webview and i want the video player in webview to enter full screen without pressing the button on video player. – Muhammad Shafique Jul 26 '22 at 14:05
60

Use setEnabledSystemUIMode (Recommended):

  • Fullscreen (with restoration):

    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
    
  • Fullscreen (without restoration):

    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
    
  • Showing a particular overlay:

    SystemChrome.setEnabledSystemUIMode(
      SystemUiMode.manual,
      overlays: [
        SystemUiOverlay.top, // Shows Status bar and hides Navigation bar
      ],
    );
    
  • Exit fullscreen:

    SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
    

Restoration: Once the status and navigation bar are presented, they will be hidden again.

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
  • `SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);` is not for Exiting full screen. From doc: `The system overlays will not disappear or reappear in this mode as they are permanently displayed on top of the application.` – Davoud Jan 31 '22 at 13:45
  • 1
    This answer should be used to update the accepted one: we should use `setEnabledSystemUIMode` over `setEnabledSystemUIOverlays`, since the latter is now deprecated. – venir Mar 24 '22 at 15:12
  • @venir Or you could say *This should be the accepted answer* now ;) – CopsOnRoad Mar 24 '22 at 16:00
  • @CopsOnRoad yes, totally, my bad. – venir Mar 24 '22 at 17:40
53
// to hide only bottom bar:
SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.top]);

// to hide only status bar: 
SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.bottom]);

// to hide both:
SystemChrome.setEnabledSystemUIOverlays ([]);
SilSur
  • 495
  • 1
  • 6
  • 21
Jawad
  • 966
  • 10
  • 10
14

Finally i found a way to set in one class for fullscreen. and disable on other classes.

To set full screen put this code in initState()

SystemChrome.setEnabledSystemUIOverlays([]);

and to set back to normal. In dispose()

SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);

in the same class.

@override
  void dispose() {
        SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
    super.dispose();
  }
    
  @override
  initState() {
      SystemChrome.setEnabledSystemUIOverlays([]);
    super.initState();
  }

you can't set the

SystemChrome.restoreSystemUIOverlays();

in dispose(). because its already saying

**Restores the system overlays to the last settings provided via [setEnabledSystemUIOverlays].**
May be used when the platform force enables/disables UI elements.
          
For example, when the Android keyboard disables hidden status and navigation bars,
this can be called to re-disable the bars when the keyboard is closed.
          
On Android, the system UI cannot be changed until 1 second after the previous
change. This is to prevent malware from permanently hiding navigation buttons.`
The Billionaire Guy
  • 3,382
  • 28
  • 31
SoloWolf93
  • 1,090
  • 11
  • 25
9

Below code is working perfect for fullscreen

SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
import 'package:flutter/services.dart'; 
////

@override
Widget build(BuildContext context) {
///Set color status bar
 SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
   return Scaffold(
   backgroundColor: Colors.white,
   body: Center(
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Image.asset(
          'images/ic_splash_logo.png',
          width: 97.0,
          height: 115.0,
          fit: BoxFit.contain,
        ),
        SizedBox(
          height: 10.0,
        ),
        Text(
          'iComplain',
          style: TextStyle(fontSize: 24,
              color: Color(0xFF174D73),
            fontFamily: 'Helvetica'
          ),
        ),
      ],
     ),
    ),
  );
}
Makamu Evans
  • 491
  • 1
  • 10
  • 25
Faisal Ahmed
  • 816
  • 9
  • 12
7

SystemChrome.setEnabledSystemUIOverlays([]);

This hides the top and bottom bars but the app size remains the same. It does not expand to full screen height.

rohittheozzy
  • 309
  • 3
  • 4
4

this is my experience if i add SystemChrome.setEnabledSystemUIOverlays([]); in init or dispose , status bar and navigation bar will back when you use keyboard , but if you use it like this it work perfect:

  @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));
      }
    }

inside of your widget

Zoha Shobbar
  • 446
  • 8
  • 17
2

Use SystemChrome.setEnabledSystemUIOverlays([]); in your main, you can use WidgetsFlutterBinding.ensureInitialized(); beforehand if you get errors.

But, this does not persist through the app, and after a textfield loses focus you're supposed to call SystemChrome.restoreSystemUIOverlays() after 1 second. Apparently "This is to prevent malware from permanently hiding navigation buttons". (Why not just keep the swipe down gesture to prevent being 'stuck inside' the app? ) in any case My app is full of forms and that method seems like a lot of work.

I guess this solution is a bit hacky but i just created a service running in the background on a timer every second running SystemChrome.restoreSystemUIOverlays() it looks like this:

    class FullscreenService{
  
    Timer? timer;
    static FullscreenService? _instance;
    FullscreenService._internal() {
    timer = Timer.periodic(
    Duration(seconds: 1), (Timer t) => 
    SystemChrome.restoreSystemUIOverlays);
    }

    factory FullscreenService() => _instance ?? FullscreenService._internal();

    void cancelTimer(){
    timer!.cancel();
   }
  }

I'm hoping i wont have to use this in the future and if anyone has any ideas how to avoid this while still maintaining fullscreen please let me know... but at least its working for now.

Lewy
  • 51
  • 4
  • In case you want your app to always be in the immersive mode, you can just use `SystemUiMode.immersiveStick`. This will automatically reset any overlays after a certain delay. This however does not work for manual mode when you just want to hide status bar e.g. – tmaihoff Nov 03 '21 at 18:00
  • btw, it must be: `Duration(seconds: 1), (Timer t) => SystemChrome.restoreSystemUIOverlays())}`. Brackets were missing – tmaihoff Nov 03 '21 at 18:00
  • 1
    and even better: you can use `SystemChrome.setSystemUIChangeCallback()` to listen to system ui mode changes. Then you don't need a permanently running timer – tmaihoff Nov 03 '21 at 18:12
2

In new version Flutter use this code:

SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);

or

 SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
Nikolay
  • 603
  • 1
  • 6
  • 13
2

Use this pub package to do in a clean way.

If you want to enable it for specific screen, make sure this screen is a StatefulWidget (you can easily convert it with your IDE tools) and override the initState() and dispose():

import 'package:fullscreen/fullscreen.dart';

class ClockScreen extends StatefulWidget {
  const ClockScreen({Key? key}) : super(key: key);

  @override
  State<ClockScreen> createState() => _ClockScreenState();
}

class _ClockScreenState extends State<ClockScreen> {

  @override
  void initState(){
    FullScreen.enterFullScreen(FullScreenMode.EMERSIVE_STICKY);
    super.initState();
  }
  
  @override
  void dispose(){
    FullScreen.exitFullScreen();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    ...
  }

1

Use SystemChrome.setEnabledSystemUIOverlays([]); in your initState() like this:

  void initState() {
    super.initState();
    print("Splash");

    // Start full screen
    SystemChrome.setEnabledSystemUIOverlays([]);
  }

to start the screen in full-screen mode.

Next use SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); in your dispose() function to exit full-screen mode for next screens.

  void dispose() {
    super.dispose();
    // Exit full screen
    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
  }
1

Update:

To Enable full screen in flutter app in your stateless or stateful widget

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);

To exit the full screen mode

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);

Example

@override
  void initState() {
    // Start full screen
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
    // Exit full screen
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
  }
Quick learner
  • 10,632
  • 4
  • 45
  • 55
0

using SystemChrome.setEnabledSystemUIOverlays([]); in initState() or build() method calling WidgetsFlutterBinding.ensureInitialized(); which is rebuilding the widget and calling the build() method twice, to resolve this issue, I am using this function into my main() function

void main() {

SystemChrome.setEnabledSystemUIOverlays([]);
...
...
..
.
MRazaImtiaz
  • 1,964
  • 1
  • 13
  • 23
-20

The AppBar is your Navigation bar so just remove it from your Code as illustrate below

//New This Code it should work , the AppBar is navigation bar

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {      
   @override
   Widget build(BuildContext context) {
      return new MaterialApp(
         home: new Scaffold(
           body: new Center(
              child: new Text('Hello World'),
           ),
         ),
      );
   }
}
Aris Ngoy
  • 122
  • 1
  • 5