flutter 隱藏導(dǎo)航欄appBar

當(dāng)有的BottomNavigationBar對(duì)應(yīng)的初始頁面不需要導(dǎo)航欄APPBar,但是需要用到appBar進(jìn)行頁面跳轉(zhuǎn)時(shí),可以先隱藏APPBar,在AppBar外包裹一層Offstage,具體代碼如下:

 //初始值
  var _currentIndex = 0;
  var appTitle = ['首頁','病例','商城','我的'];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
       appBar: PreferredSize(
          child: Offstage(
              offstage: _currentIndex == 3?true:false,
              child: AppBar(
                  centerTitle:true ,
                  title: Text(appTitle[_currentIndex]),
              
                  //  toolbarOpacity:_currentIndex==3?0:1 ,
                  backgroundColor: _currentIndex!= 3? 
                  Theme.of(context).accentColor:Colors.transparent,
            ),
        ),
         preferredSize:Size.fromHeight(MediaQuery.of(context).size.height * 0.07),
        ),
       body: getCurrentPage(),
       bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
         items: <BottomNavigationBarItem>[
            BottomNavigationBarItem(icon: Icon(Icons.home), title: Text(appTitle[0])),
            BottomNavigationBarItem(icon: Icon(Icons.business), title: Text(appTitle[1])),
            BottomNavigationBarItem(icon: Icon(Icons.local_mall), title: Text(appTitle[2])),
            BottomNavigationBarItem(icon: Icon(Icons.person), title: Text(appTitle[3])),
       ],
       currentIndex:_currentIndex,
       fixedColor: Colors.deepPurple,
       onTap: _clickBottermIterm,
       ),
    );
  }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 原文地址 Flutter是谷歌推出的一款全新的移動(dòng)app SDK。它旨在幫助開發(fā)人員和設(shè)計(jì)師為Android和IO...
    Sper_CL閱讀 798評(píng)論 0 1
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML標(biāo)準(zhǔn)。 注意:講述HT...
    kismetajun閱讀 28,797評(píng)論 1 45
  • 1.App結(jié)構(gòu)和導(dǎo)航 Scaffold:Material Design布局結(jié)構(gòu)的基本實(shí)現(xiàn)。此類提供了用于顯示dra...
    慕容小偉閱讀 4,090評(píng)論 0 3
  • 第1步:創(chuàng)建初始Flutter應(yīng)用 創(chuàng)建一個(gè)簡(jiǎn)單的 Flutter 應(yīng)用。主要編輯 Dart 代碼所在的 lib ...
    小白_Sing閱讀 1,074評(píng)論 0 0
  • // print和debugPrint //在定義和實(shí)現(xiàn)一個(gè)類型的時(shí)候,Swift中的一種非常常見,也是非常先進(jìn)的...
    fordring2008閱讀 1,595評(píng)論 0 0

友情鏈接更多精彩內(nèi)容