Flutter-有没有办法设置所有AppBars高程

问题描述 投票:3回答:2

我想将所有页面AppBarelevation设置为0。 我必须单独设置吗? 或者有没有办法将其设置为所有页面? 先感谢您!

flutter appbar
2个回答
7
投票

创建自己的AppBar小部件,并在所有屏幕中使用它

  import 'package:flutter/material.dart';

  class MyAppBar extends AppBar {
    MyAppBar(
        {Key key,
       Widget title,
        Color backgroundColor,
        List<Widget> actions,
        PreferredSizeWidget bottom})
        : super(
            backgroundColor: backgroundColor,
            title: title,
            actions: actions,
            bottom: bottom,
            elevation:
                0.0,
          );
  }

0
投票

正如我在app_bar.dart文件中看到的那样,给应用栏的默认高程是4.0,您可以将其更改为0.0。我认为这样就可以了。

© www.soinside.com 2019 - 2024. All rights reserved.