删除SliverAppBar底部边框-Flutter

时间:2019-07-15 05:42:15

标签: flutter dart flutter-layout

enter image description here

我要删除上图中突出显示的边框。我找不到任何解决方案来解决这个问题:(

这是我的SliverAppBar代码:

SELECT *
FROM ProductAndServices
WHERE
    (@Title IS NULL OR Title = @Title) AND
    (@CreatedBy IS NULL OR CreatedBy = @CreatedBy)

3 个答案:

答案 0 :(得分:1)

只需将elevation属性设置为0

 SliverAppBar(
                  title: Text('Applying to this job opportunity'),
                  pinned: true,
                  elevation: 0,
                  titleSpacing: 0,
                  floating: true,
                  expandedHeight: 180,
                  flexibleSpace: //some widgets
             )

更多信息:https://api.flutter.dev/flutter/material/SliverAppBar/elevation.html

答案 1 :(得分:0)

我来到这里想知道如何去除阴影,但要保留边框。答案是:

elevation中的SliverAppBar设置为1

SliverAppBar(
  elevation: 1,
  // ...
)

结果:

flutter app bar show bottom border without shadow

答案 2 :(得分:0)

在我看来,底部边框仍然显示。它与此问题有关 https://github.com/flutter/flutter/issues/16262

因此,我必须将 Scaffold 的背景设置为与子小部件的背景相同才能解决此问题。

似乎只发生在某些手机上。

https://github.com/flutter/flutter/issues/16262#issuecomment-379071933

<块引用>

如果您将 Scaffold 的主体包含在 SizedBox.expand 小部件中,则 body 将始终填充剩余空间。然后,正如你所指出的, 指定 Scaffold 的 backgroundColor,隐藏问题。

-> 有问题

    for (Entity * cb : cbs)
    {
        delete cb;
    }

enter image description here

-> 通过添加背景修复

Widget build(BuildContext context) {
    return Scaffold(
        body: CustomScrollView(
          controller: _scrollController,
          slivers: <Widget>[
            SliverAppBar(
                pinned: true,
                snap: false,
                floating: false,
                elevation: 0.0, // Remove AppBar bottom border
                leading: new Container(),
                titleSpacing: 0,
                expandedHeight: 100.0,
                flexibleSpace: LayoutBuilder(
                    builder: (BuildContext context, BoxConstraints constraints) {
                      top = constraints.biggest.height;
                      return FlexibleSpaceBar(
                        centerTitle: true,
                        titlePadding: EdgeInsets.zero,
                        title: top >= 86
                            ? null
                            : topToolBarWidget(),
                        background: sliverBackgroundWidget()
                      );
                    })),
            SliverList(
              delegate: SliverChildListDelegate(
                [
                  PromotionSlider()
                ],
              ),
            ),
          ],
        ));
  }

enter image description here

相关问题