如何摆脱扑朔迷离的appbar和tabbar之间的空间?

时间:2020-08-10 09:31:34

标签: flutter padding space tabbar appbar

我正在尝试做,但是我不知道怎么做

enter image description here

我想摆脱绿色空间。 我正在尝试使用PreferedSize小部件,但是它不起作用,我的代码是...

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: PreferredSize(
        preferredSize: Size.fromHeight(SizeConfig.heightMultiplier * 6.2),
// it's pretty narrow size but doesn't work in this screen but others
        child: Scaffold(
          appBar: AppBar(
            centerTitle: true,
            title: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'hello',
                  style: TextStyle(fontWeight: FontWeight.bold),
                ),
                Text(
                  'world',
                ),
                Text(
                  '!',
                  style: TextStyle(fontWeight: FontWeight.bold),
                ),
              ],
            ),
            actions: <Widget>[
              Icon(
                Icons.add,
                color: Colors.transparent,
              ),
            ],
            backgroundColor: Theme.of(context).primaryColor,
            bottom: TabBar(
              controller: tabController,
              indicatorColor: Colors.white,
              tabs: myTabs,
            ),
          ),
...

我需要你的帮助☑

1 个答案:

答案 0 :(得分:1)

用高度为0(或较小高度)的TabBar小部件包裹PreferredSize

bottom: PreferredSize(
          preferredSize: Size.fromHeight(0),
          child: TabBar(
            controller: tabController,
            indicatorColor: Colors.white,
            tabs: myTabs,
          ),
        ),