web-dev-qa-db-ja.com

Flutter / Dart:下部ナビゲーションバーの高さをカスタマイズ

BottomNavigationBarの高さをカスタマイズする方法はありますか?

私は現在、タップ/スワイプナビゲート用のタブを備えたBottomNavigationBarを持っていますが、デフォルトの高さ(テキストとアイコンを減らした後でも)が高すぎます。

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    backgroundColor: Colors.blue,
    title: Text( 'RefLog', style: Styles.headerLarge ),
    actions: <Widget>[
      new IconButton(
        icon: Icon(Icons.list),
        onPressed: () {},
      )
    ],
  ),
  body: DefaultTabController(
    length: 3,
    child: Scaffold(
      body: TabBarView(
        children: _children,
      ),
      bottomNavigationBar: TabBar(
        tabs: [
          Tab( text: 'One', icon: Icon(Icons.import_contacts, size: 20.0) ),
          Tab( text: 'Two', icon: Icon(Icons.restaurant, size: 20.0) ),
          Tab( text: 'Three', icon: Icon(Icons.record_voice_over, size: 20.0) ),
        ],
        labelStyle: TextStyle(fontSize: 12.0),
        labelColor: Colors.white,
        unselectedLabelColor: Colors.white30,
        indicatorSize: TabBarIndicatorSize.label,
        indicatorColor: Colors.white,
      ),
      backgroundColor: Colors.blue,
    ),
  ),
 );
}
7
Jesse

私は同じ問題を抱えていましたが、BottomNavigationBarの高さは上書きできません。私のソリューションはSizedBoxを使用してアイコンのサイズを変更しました。タイトルプロパティのフォントサイズを更新しました、これは私の例です:

new BottomNavigationBarItem(
              icon:new SizedBox(
                child: new IconButton(
                    icon: new Image.asset("assets/images/icon_ar.png"),
                    onPressed: () {}),
                width: 38,
                height: 38,
              ),
              title: new Text("", style: new TextStyle(fontSize: 0),))

これは私のBottomNavigationBarが両方のプラットフォームで標準サイズであったことを示しています。

0