简体   繁体   English

在 DefaultTabController 中的 AppBar 周围填充

[英]Padding around AppBar in a DefaultTabController

I'm using a DefaultTabController with a Scaffold as the child widget.我正在使用带有 Scaffold 的 DefaultTabController 作为子小部件。 For the appBar, I'm using a TabBar.对于 appBar,我使用的是 TabBar。 I'd like to add some padding around the TabBar but the appBar property requires a class that extends PreferredSizeWidget.我想在 TabBar 周围添加一些填充,但 appBar 属性需要一个扩展 PreferredSizeWidget 的类。

Example snippet of the tab controller I'm building:我正在构建的选项卡控制器的示例片段:

  new DefaultTabController(
    length: tabs.length,
    child: new Scaffold(
      backgroundColor: const Color(0xFFF3EEE1),
      appBar: new TabBar(
        tabs: tabs,
      ),
      body: new TabBarView(
        children: _testPacks.map((TestPack testPack) {
          return _contentWidget(context: context, testPack: testPack);
        }).toList(),
      ),
    ),
  );

From the Scaffold class来自 Scaffold 类

/// An app bar to display at the top of the scaffold.
final PreferredSizeWidget appBar;

Now you can pass your custom padding现在您可以传递您的自定义填充

 TabBar(
      labelPadding: EdgeInsets.all(0),

您可以将TabBarContainerPreferredSize

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

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