【发布时间】:2020-12-28 02:13:06
【问题描述】:
我正在寻找一种禁用 Flutter 可视化调试的方法:(在 Chrome 模拟器上使用 VSCode、Flutter Web)
正如您所见,即使我的主题非常简单,没有底色或颜色,它也会添加一堆不需要的东西。 我已经在代码中和通过选项禁用了 debugPaint,但这仍然存在。
以下是在 MaterialApp 层面导入的主题:
theme: ThemeData(
primarySwatch: Colors.blue,
)
还有截图中显示的卡片本身:
@override
Widget build(BuildContext context) {
print('Adding article: ' + article.title);
return Column(children: [
Container(
height: 30,
width: 30,
decoration: BoxDecoration(
border: Border.all(width: 3.0),
),
child: Text(article.title),
),
Text(
article.title,
style: TextStyle(fontSize: 21, fontWeight: FontWeight.bold),
),
Text(
article.description,
style: TextStyle(fontSize: 16, color: Colors.grey[500]),
),
Text(
article.publishDate,
style: TextStyle(fontSize: 14, color: Colors.grey[300]),
)
]);
}
}
附加说明:将 debugLines 设置为 true 会添加更多元素:
【问题讨论】:
-
我猜
debugPaintBaselinesEnabled设置为true -
我将所有我知道的 debugPaint 设置为 false:debugPaintPointersEnabled = debugPaintBaselinesEnabled = debugPaintLayerBordersEnabled = debugRepaintRainbowEnabled = false;
-
您有
Scaffold作为您的小部件的父级吗? -
谢谢我把导航搞砸了,这个屏幕没有脚手架。它解决了这个问题。编辑:如何将您的评论标记为答案?
-
然后随意写一个自我答案;-)
标签: flutter debugging visual-studio-code