Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

firebase - Flutter problem size icon in tabbar in appbar?

I have a little problem I can't find the solution. I created a TABBAR in an APPBAR, but I cannot resize it so that my icon of my tabbar is visible.

My tabbar its ok, but size of icon and tab not good...

I tried several ways but none worked ...

My problem: My probleme

My code:

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>
    with SingleTickerProviderStateMixin {
  TabController _tabcontroller;
  @override
  void initState() {
    super.initState();
    _tabcontroller = new TabController(length: 3, vsync: this);
    _tabcontroller.addListener(() {
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar:  AppBar(
          backgroundColor: Colors.white,
          automaticallyImplyLeading: false,
          elevation: 1,
          title: new TabBar(
              indicatorColor: Colors.transparent,
              controller: _tabcontroller,
              tabs: [
                new SafeArea(
                  child: new Container(
                    padding: EdgeInsets.all(ScreenUtil().setWidth(20.0)),
                    child: Center(
                      child: new Icon(
                        Icons.icecream,
                        color: _tabcontroller.index == 0
                            ? Theme.of(context).primaryColor
                            : Colors.grey,
                        size: ScreenUtil().setSp(80.0),
                      ),
                    ),
                  ),
                ),
                new SafeArea(
                  child: new Container(
                    padding: EdgeInsets.all(ScreenUtil().setWidth(20.0)),
                    child: Center(
                      child: new Icon(
                        Tinder_clone.iconfinder_338_tinder_logo_4375488__1_,
                        color: _tabcontroller.index == 1
                            ? Theme.of(context).primaryColor
                            : Colors.grey,
                        size: ScreenUtil().setSp(80.0),
                      ),
                    ),
                  ),
                ),
                new SafeArea(
                  child: new Container(
                    padding: EdgeInsets.all(ScreenUtil().setWidth(20.0)),
                    child: Center(
                      child: new Icon(
                        Tinder_clone.iconfinder_message_01_186393,
                        color: _tabcontroller.index == 2
                            ? Theme.of(context).primaryColor
                            : Colors.grey,
                        size: ScreenUtil().setSp(80.0),
                      ),
                    ),
                  ),
                ),
              ]),
        ),
           
question from:https://stackoverflow.com/questions/65946373/flutter-problem-size-icon-in-tabbar-in-appbar

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When placing TabBar within the AppBar, you should use the bottom property.

// ... other lines

return new Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        automaticallyImplyLeading: false,
        elevation: 1,
        bottom: new TabBar(
            indicatorColor: Colors.transparent,
            controller: _tabcontroller,

// ... other lines

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...