How to change background color of TabBar without changing the AppBar in flutter?

后端 未结 3 1058
我在风中等你
我在风中等你 2020-12-24 12:41

How to change background color of TabBar without changing the AppBar? The TabBar does not have a background property, is

3条回答
  •  粉色の甜心
    2020-12-24 13:18

    Create a simple Widget for this, cannot be simpler:

    class ColoredTabBar extends Container implements PreferredSizeWidget {
      ColoredTabBar(this.color, this.tabBar);
    
      final Color color;
      final TabBar tabBar;
    
      @override
      Size get preferredSize => tabBar.preferredSize;
    
      @override
      Widget build(BuildContext context) => Container(
        color: color,
        child: tabBar,
      );
    }
    

提交回复
热议问题