【发布时间】:2018-08-07 11:25:02
【问题描述】:
在 Flutter 中使用 Scaffold 小部件时,有没有办法去除应用栏(AppBar 类)下的阴影?
【问题讨论】:
标签: flutter dart shadow appbar flutter-widget
在 Flutter 中使用 Scaffold 小部件时,有没有办法去除应用栏(AppBar 类)下的阴影?
【问题讨论】:
标签: flutter dart shadow appbar flutter-widget
如果您想在不重复代码的情况下移除所有应用栏的阴影,只需在您的 MaterialApp 小部件内将带有 elevation: 0 的 AppBarTheme 属性添加到您的应用主题 (ThemeData):
// This code should be located inside your "MyApp" class, or equivalent (in main.dart by default)
return MaterialApp(
// App Theme:
theme: ThemeData(
// ••• ADD THIS: App Bar Theme: •••
appBarTheme: AppBarTheme(
elevation: 0, // This removes the shadow from all App Bars.
)
),
);
【讨论】:
我尝试了一些可能对你有帮助的方法
AppBar(
backgroundColor: Colors.transparent,
bottomOpacity: 0.0,
elevation: 0.0,
),
看看这个
【讨论】:
要移除 appbar 下拉阴影,请设置 AppBar 构造函数 elevation: 0.0
参数 primary、toolbarOpacity、bottomOpacity 和 automaticallyImplyLeading 不得为空。此外,如果指定了高程,则它必须为非负数。
如果 backgroundColor、elevation、shadowColor、brightness、iconTheme、actionIconTheme、textTheme 或 centerTitle 为 null,则将使用它们的 AppBarTheme 值。如果对应的 AppBarTheme 属性为 null,则将使用属性文档中指定的默认值。
appBar: AppBar(
title: Text('App Title'),
elevation: 0.0,
bottomOpacity: 0.0,
),
【讨论】: