繁体   English   中英

从 Flutter 中的 Scaffold AppBar 中删除投影?

[英]Removing the drop shadow from a Scaffold AppBar in Flutter?

在 Flutter 中使用 Scaffold 小部件时,有没有办法删除应用栏(AppBar 类)下的投影?

查看AppBar构造函数,有一个elevation属性可用于设置应用栏的高度,从而设置阴影投射量。 将此设置为零会删除阴影:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('My App Title'),
        elevation: 0,
      ),
      body: const Center(
        child: Text('Hello World'),
      ),
    );
  }

在此处输入图像描述

我试过一些可能对你有帮助的东西

AppBar(
backgroundColor: Colors.transparent,
bottomOpacity: 0.0,
elevation: 0.0,
),

看一下这个

如果您想在不重复代码的情况下删除所有应用栏的阴影,只需在您的应用程序主题( ThemeData )中添加一个带有elevation: 0AppBarTheme属性,在您的MaterialApp小部件内:

// 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.
    )
  ),
);

在Flutter中使用Scaffold小部件时,是否可以删除应用栏(AppBar类)下的阴影?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM