Albert Lardizabal
Albert Lardizabal

Reputation: 6846

Padding around AppBar in a DefaultTabController

I’m using a DefaultTabController with a Scaffold as the child widget. For the appBar, I’m using a TabBar. I’d like to add some padding around the TabBar but the appBar property requires a class that extends 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

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

Upvotes: 5

Views: 9078

Answers (2)

BIS Tech
BIS Tech

Reputation: 19424

Now you can pass your custom padding

 TabBar(
      labelPadding: EdgeInsets.all(0),

Upvotes: 11

Collin Jackson
Collin Jackson

Reputation: 116708

You can wrap your TabBar's Container in a PreferredSize.

Upvotes: 4

Related Questions