删除 Flutter PersistentFooterButtons 中的边距

Ern*_*lva 5 flutter flutter-layout

我正在尝试删除 的默认边距persistentFooterButtons,但我找不到它,因为它收到了一个小部件列表。

\n

我正在使用extendBody: trueScaffold

\n

持久页脚按钮边距

\n

持久页脚按钮边距

\n
    persistentFooterButtons: [\n    Container(\n      color: const Color.fromRGBO(240, 240, 240, 0.9),\n      width: double.infinity,\n      child: Padding(\n        padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 2),\n        child: Row(\n          children: [\n            Expanded(\n              child: GestureDetector(\n                child: Column(\n                  children: [\n                    const Image(\n                      image: AssetImage(\'assets/images/home.png\'),\n                      height: 35,\n                    ),\n                    Text(\n                      "In\xc3\xadcio",\n                      style: TextStyle(\n                        fontSize: 10,\n                        color: Theme.of(context).primaryColor,\n                      ),\n                    ),\n                  ],\n                ),\n              ),\n            ),\n          ],\n        ),\n      ),\n    )\n  ],\n
Run Code Online (Sandbox Code Playgroud)\n

Md.*_*ikh 5

这是来自 的源代码scaffold.dart。它是这样定义的。

 child: Container(
                alignment: AlignmentDirectional.centerEnd,
                padding: const EdgeInsets.all(8), //<-- this 
                child: OverflowBar(
                  spacing: 8,
                  overflowAlignment: OverflowBarAlignment.end,
                  children: widget.persistentFooterButtons!,
                ),
              ),

Run Code Online (Sandbox Code Playgroud)

源代码

如果可以在您的项目中使用它,您可以删除padding或设置您的本地计算机。0您可以根据需要在值之间进行切换。此外,您还可以为您的项目创建单独的 dart 文件。

在此输入图像描述

可以应用另一个技巧transform,但在这种情况下可以实现点击效果。

Container(
  transform: Matrix4.translationValues(0, 8, 0),
   .....
Run Code Online (Sandbox Code Playgroud)

或者我会说只是使用bottomNavigationBaronScaffold而不是persistentFooterButtons

  bottomNavigationBar: Container(
          color: const Color.fromRGBO(240, 240, 240, 0.9),
          width: double.infinity,
          height:50, // the one prefered by your view
........
Run Code Online (Sandbox Code Playgroud)