如何在flutter中删除调试横幅?
我正在使用flutter screenshot,我希望屏幕截图没有横幅.现在确实有.
请注意,我收到not supported for emulator了配置文件和发布模式的消息.
Rém*_*let 306
在你的MaterialApp设置debugShowCheckedModeBanner来false.
缓慢的横幅也将在发布版本中自动删除.
tot*_*tto 99
过时
Crs*_*ero 38
在你的班级中使用MaterialApp
debugShowCheckedModeBanner:false,
...
return new MaterialApp(
title: 'Flutter Test',
debugShowCheckedModeBanner: false,
home: new Column(
...
),
builder: (BuildContext context, Widget child) {
...
}
);
...
Run Code Online (Sandbox Code Playgroud)
loo*_*bly 34
片段
MaterialApp(
debugShowCheckedModeBanner: false,
)
Run Code Online (Sandbox Code Playgroud)
或者
ScaffoldApp(
debugShowCheckedModeBanner: false,
);
Run Code Online (Sandbox Code Playgroud)
要运行应用程序的发行版本,请使用此命令
flutter run --release
Run Code Online (Sandbox Code Playgroud)
或者如果使用真实设备而不是模拟器或模拟器。
make a build version of the app。
flutter build apk
Run Code Online (Sandbox Code Playgroud)
ctr+shift+p在 Windows 和 Mac 中输入 IN vs codecmd+shift+p并使用此命令打开 dart dev 工具
Dart: Open DevTools
Run Code Online (Sandbox Code Playgroud)
小智 21
在您的 MaterialApp 上将 debugShowCheckedModeBanner 设置为 false。
MaterialApp(
debugShowCheckedModeBanner: false,
)
Run Code Online (Sandbox Code Playgroud)
调试横幅也将在发布版本中自动删除。
如果您使用的是模拟器或真实设备并且您想在发布模式下检查它,那么=>
flutter run release --apk
Run Code Online (Sandbox Code Playgroud)
在终端 Android Studio/Vs Code 上运行此命令
Kab*_*uda 20
要删除 Flutter 调试横幅,有几种可能性:
第一个是在MaterialApp小部件中使用debugShowCheckModeBanner属性。
代码:
MaterialApp(
debugShowCheckedModeBanner: false,
)
Run Code Online (Sandbox Code Playgroud)
然后进行热重载。
第二种可能性是如果您使用Android Studio或IntelliJ IDEA ,则在 Flutter Inspector 中隐藏调试模式横幅。
第三种可能性是使用Dart DevTools。
小智 17
还有另一种方法可以从 flutter 应用程序中删除“调试”横幅。现在在新版本之后"debugShowCheckedModeBanner: false,",主 .dart 文件中没有代码行。所以我认为这些方法是有效的:
"Dart DevTools"则从扩展安装。安装后,您可以轻松地"Dart DevTools"在 VS Code 底部找到文本图标。当您单击该文本图标时,将在 google chrome 中打开一个链接。从该链接页面,您只需点击此屏幕截图中所示的横幅图标即可轻松删除横幅。注意:-- Dart DevTools是 VS Code 中的 dart 语言调试器扩展
Dart DevTools已经安装在你的 VS Code 中,那么你可以直接打开谷歌浏览器打开这个 URL ="127.0.0.1: ZZZZZ/?hide=debugger&port=XXXXX"注意:-在此链接中,将“XXXXX”替换为 5 位端口 ID(您的"flutter run"Flutter应用程序在其上运行),这将在您使用命令时发生变化,并用您的全局(不可更改)5 位调试器 ID 替换“ZZZZZ”
注意:-- 这些 dart 开发工具仅适用于“Google Chrome 浏览器”
Muh*_*qib 16
使用:
MaterialApp(
debugShowCheckedModeBanner: false,
)
Run Code Online (Sandbox Code Playgroud)
这是删除此横幅的代码。调试横幅是由 MaterialApp 引起的,例如,您可以在所有使用MaterialApp 的页面上看到此横幅。
您的应用程序的主根目录中应该至少有一个 MaterialApp。
ale*_*ari 16
所有其他答案都非常适合 Android Studio,但如果使用 Visual Studio Code,您可以使用一个命令轻松切换此功能。打开命令面板(Mac:++Cmd或Windows :++ )。然后输入切换调试模式横幅,如下所示:ShiftPCtrlShiftP
Par*_*iya 14
Here are 3 ways to do it
1 :
On your MaterialApp set debugShowCheckedModeBanner to false.
MaterialApp(
debugShowCheckedModeBanner: false
)
Run Code Online (Sandbox Code Playgroud)
The slow banner will also automatically be removed on release build.
2 : If you are using Android Studio, you can find the option in the Flutter Inspector tab --> More Actions.
3 : There is also another way for removing the "debug" banner from the flutter app. Now after new release there is no "debugShowCheckedModeBanner: false," code line in main. dart file. So I think these methods are effective:
--> If you are using VS Code, then install "Dart DevTools" from extensions. After installation, you can easily find "Dart DevTools" text icon at the bottom of VS Code. When you click on that text icon, a link will be open in google chrome. From that link page, you can easily remove the banner by just tapping on the banner icon as shown.
Credit to : How_to_remove_debug_banner_in_flutter_on_android_emulator
Jit*_* Kt 13
MaterialApp(
debugShowCheckedModeBanner: false
)
Run Code Online (Sandbox Code Playgroud)
小智 12
如果使用的是IntelliJ IDEA,则颤振检查器中有一个选项可以将其禁用。
运行项目
在Flutter Inspector中时,单击或选择“更多操作”。
出现菜单时,选择“隐藏调试模式横幅”
这是app.dart类属性。
在检查模式下运行时,它会显示一个横幅,显示“DEBUG”。MaterialApp 默认构建其中之一。
为了在调试模式下禁用此横幅,您可以设置布尔值 false。
return MaterialApp(
theme:....
debugShowCheckedModeBanner: false,
home: SplashScreen(),
);
Run Code Online (Sandbox Code Playgroud)
在发布模式下这没有任何效果。
如果您仍处于调试模式,可以切换到发布模式,横幅将会消失。
您还可以通过快捷方式打开相同的运行/调试配置窗口:
ALT+ SHIFT+ F10,然后按0并按ALT+ a。
现在输入--release.
好吧,这是您想要的简单答案。
MaterialApp(
debugShowCheckedModeBanner: false
)
Run Code Online (Sandbox Code Playgroud)
但是,如果您想深入了解应用程序(想要发布apk(没有调试横幅)),并且如果您使用的是android studio,请转到
运行-> Flutter以Relese模式运行'main.dart'
调试横幅仅在开发时出现,并在发布版本中自动删除。
要隐藏这一点,需要设置debugShowCheckedModeBanner为false
MaterialApp(
debugShowCheckedModeBanner: false,
)
Run Code Online (Sandbox Code Playgroud)
如果您Scaffold在退货部分使用,请添加在顶部MaterialApp和Restart
void main() => runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: Home()),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
47807 次 |
| 最近记录: |