ChatGPT解决这个技术问题 Extra ChatGPT

How can I remove the Flutter debug banner?

How can I remove the debug banner in Flutter?

I am using flutter screenshot and I would like the screenshot not to have a banner. Now it does have.

Note that I get not supported for emulator message for profile and release mode.

debugShowCheckedModeBanner: false
add debugShowCheckModeBanner:false in MaterialApp() Widget and that should remove the banner on hot reload
debugShowCheckModeBanner: false in MaterialApp - most used one. You can also disable it using Android Studio. 3 Ways To Remove Debug Banner In Flutter

c
creativecreatorormaybenot

On your MaterialApp set debugShowCheckedModeBanner to false.

MaterialApp(
  debugShowCheckedModeBanner: false,
)

The debug banner will also automatically be removed on release build.


Usage: return new MaterialApp( home: new LoginPage(), debugShowCheckedModeBanner: false, theme: new ThemeData( primarySwatch: Colors.green, ));
do i need to use debugShowCheckedModeBanner: false on each class means activity ?
The flutter tool's built-in screenshot command also knows how to automatically remove the "debug" banner while taking a screenshot if that's helpful.
@EricSeidel Not by default it doesn't (Flutter 1.16.4-pre.18 • channel master • github.com/flutter/flutter.git Framework • revision c8efcb632b (6 weeks ago) • 2020-03-27 22:31:01 -0700 Engine • revision 3ee9e3d378) Is there a trick to enable this?
Is there any way to show it in release build? I am building a release versions but for dev/production environments
P
Peter Mortensen

Outdated

If you are using Android Studio, you can find the option in the Flutter Inspector tab → More Actions.

Or if you're using Dart DevTools, you can find the same button in the top right corner as well.


Disappeared on the DevTools View, but I have found it through AndroidStudio
P
Peter Mortensen

Well, this is the simple answer you want.

MaterialApp(
  debugShowCheckedModeBanner: false
)

CupertinoApp(
  debugShowCheckedModeBanner: false
)

But if you want to go deep with the app (want a release APK file (which doesn't have a debug banner) and if you are using Android Studio then go to Run → Flutter → Run 'main.dart' in Release mode.


P
Peter Mortensen

If you are using IntelliJ IDEA, there is an option in the Flutter Inspector to disable it.

Run the project:

https://i.stack.imgur.com/gEEtcm.png

https://i.stack.imgur.com/oUzjKm.png

When you are in the Flutter Inspector, click or choose "More Actions."

https://i.stack.imgur.com/EiW1fm.png

When the menu appears, choose "Hide Debug Mode Banner":

https://i.stack.imgur.com/xasEem.png


This menu and related item doesn't exist in idea 2020.3 and flutter 55.0.3
P
Peter Mortensen

There is also another way for removing the "debug" banner from the Flutter app. Now after a new release there is no "debugShowCheckedModeBanner: false," code line in the main .dart file. So I think these methods are effective:

If you are using Visual Studio Code, then install `"Dart DevTools" from extensions. After installation, you can easily find the "Dart DevTools" text icon at the bottom of Visual Studio Code. When you click on that text icon, a link will be opened in Google Chrome. From that link page, you can easily remove the banner by just tapping on the banner icon as shown in this screenshot.

NOTE: Dart DevTools is a Dart language debugger extension in Visual Studio Code

If Dart DevTools is already installed in your Visual Studio Code, then you can directly open Google Chrome and open the URL "127.0.0.1: ZZZZZ/?hide=debugger&port=XXXXX"

Note: In this link, replace "XXXXX" by 5 digit port-id (on which your Flutter app is running) which will vary whenever you use the flutter run command and replace "ZZZZZ" by your global (unchangeable) 5 digit debugger-id

Note: These Dart developer tools are only for the Google Chrome browser


J
Javeed Ishaq

The debug banner appears only while in development and is automatically removed in the release build.

To hide this there is a need to set debugShowCheckedModeBanner to false

MaterialApp(
  debugShowCheckedModeBanner: false,
)

https://i.stack.imgur.com/IWHUV.gif


L
Loop_Assembly

Three ways to remove flutter debug banner:

1. In the MaterialApp/ScaffoldApp

Snippet

MaterialApp(
  debugShowCheckedModeBanner: false,
)

OR

ScaffoldApp(
             debugShowCheckedModeBanner: false,
        );

2.By making release version of your app

For running release version of your app, use this command

flutter run --release

Or if using real devices rather than emulators or simulators. make a build version of the app.

flutter build apk

3.BY using dart dev tool to remove debug banner

IN vs code type ctr+shift+pin windows and for mac cmd+shift+p and use this command to open dart dev tool

Dart: Open DevTools

https://i.stack.imgur.com/ssaXa.png


A
Awais Rehman

On your MaterialApp set debugShowCheckedModeBanner to false.

 MaterialApp(
    debugShowCheckedModeBanner: false,
  )

The debug banner will also automatically be removed on release build.

If you are using emulator or real device and you want to check it on release mode then =>

   flutter run release --apk 

run this command on terminal Android Studio / Vs Code


P
Peter Mortensen

Use:

MaterialApp(
  debugShowCheckedModeBanner: false,
)

This is the code for removing this banner. The debug banner is due to MaterialApp, e.g., you can see this banner on all that pages that use MaterialApp.

There should be at least one MaterialApp in your app on main root.


P
Peter Mortensen

All other answers are great for Android Studio, but if using Visual Studio Code there is a command you can use to toggle this easily. Open the command palette (Mac: Cmd + Shift + P or Windows: Ctrl + Shift + P). Then type toggle debug-mode banner as shown below:

https://i.stack.imgur.com/tgKh6.png


P
Peter Mortensen

To remove the Flutter debug banner, there are several possibilities:

The first one is to use the debugShowCheckModeBanner property in your MaterialApp widget. Code: MaterialApp( debugShowCheckedModeBanner: false, ) And then do a hot reload. The second possibility is to hide debug mode banner in Flutter Inspector if you use Android Studio or IntelliJ IDEA. The third possibility is to use Dart DevTools.


This menu and related item doesn't exist in idea 2020.3 and flutter 55.0.3
j
jmizv

In a Material app set debugShowCheckedModeBanner to false.


A
Aymen

official example

MaterialApp(
  home: Scaffold(
    appBar: AppBar(
      title: const Text('Home'),
    ),
  ),
  debugShowCheckedModeBanner: false, //setup this property
)

for more information, view the official documentation.


A
Adie RT

Just do this in your MaterialApp or GetMaterialApp add this line debugShowCheckedModeBanner to false.

like this

MaterialApp(
  debugShowCheckedModeBanner: false,
)

v
vs97

If you are still in debug mode, you can switch to release mode and the banner will be gone.

https://i.stack.imgur.com/qSXnw.png

https://i.stack.imgur.com/V600F.png

You can also open the same Run/Debug Configurations window via shortcuts:

ALT+SHIFT+F10, then Press 0 and Press ALT+a.

Now enter --release.


P
Peter Mortensen

It's the app.dart class property.

It displays a banner, saying "DEBUG" when running in checked mode. MaterialApp builds one of these by default.

For disabling this banner in debug mode also, you can set a Boolean false.

return MaterialApp(
  theme:....
  debugShowCheckedModeBanner: false,
  home: SplashScreen(),
);

In release mode this has no effect.


S
Sarthak Raval

If you use Scaffold in Return Section so add on Top MaterialApp and Restart

void main() => runApp(
      const MaterialApp(
                 debugShowCheckedModeBanner: false, 
                 home: Home()),
      );

m
murat

You can use debugShowCheckedModeBanner inside MaterialApp:

return MaterialApp(
  debugShowCheckedModeBanner: false,
  ...
);

K
Kesselly Kamara

Go to main in the Lib folder find MaterialApp() and type debugShowCheckedModeBanner: false,

MaterialApp( debugShowCheckedModeBanner: false, )


M
MNBWorld

use this

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: AppTheme.appTheme,
      home: HomePage(),
    );
  }
}