DefaultTabController 中 AppBar 周围的填充

Alb*_*bal 5 dart flutter

I\xe2\x80\x99m 使用 DefaultTabController 和 Scaffold 作为子部件。对于appBar,I\xe2\x80\x99m 使用TabBar。I\xe2\x80\x99d 喜欢在 TabBar 周围添加一些填充,但 appBar 属性需要一个扩展 PreferredSizeWidget 的类。

\n\n

我正在构建的选项卡控制器的示例片段:

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

来自脚手架类

\n\n
/// An app bar to display at the top of the scaffold.\nfinal PreferredSizeWidget appBar;\n
Run Code Online (Sandbox Code Playgroud)\n

Blo*_*oss 11

现在您可以传递自定义填充

 TabBar(
      labelPadding: EdgeInsets.all(0),
Run Code Online (Sandbox Code Playgroud)


Col*_*son 4

您可以将您的TabBar包裹ContainerPreferredSize.