【问题标题】:BottomNavigationbar: How to make the child container's height the same as the bar's?BottomNavigationbar:如何使子容器的高度与栏的高度相同?
【发布时间】:2022-11-04 16:08:10
【问题描述】:

我想为我的Flutter 应用程序创建一个bottomnavigationbar,其中将包含公司的徽标和并排的文本。这是我的代码:

bottomNavigationBar: Container(
  padding: const EdgeInsets.all(10),
  alignment: Alignment.bottomCenter,
  width: MediaQuery.of(context).size.width,
  height: 100, //how do I make it the default height of the bottomnavbar?
  decoration: BoxDecoration(
      color: Colors.yellow,
      border: Border.all(
          color: Colors.black, // Set border color
          width: 3.0),   // Set border width
      borderRadius: const BorderRadius.all(
          Radius.circular(10.0)), // Set rounded corner radius
      boxShadow: const [BoxShadow(blurRadius: 10,color: Colors.black,offset: Offset(1,3))] // Make rounded corner of border
  ),
  child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: const <Widget>[
        Image(
          image: AssetImage('images/company_logo.png'),
          height: 90,
        ),
        SizedBox(
          width: 15,
        ),
        Text("DEVELOPED BY COMPANY_NAME",style: TextStyle(fontWeight: FontWeight.bold, fontFamily: 'Lobster'))
      ]
  )
)

我希望孩子Container() 的高度与底部导航栏的默认高度相同。我该如何进行?

【问题讨论】:

    标签: flutter


    【解决方案1】:
    bottomNavigationBar: Container(
      padding: const EdgeInsets.all(10), //get error with image height remove this
      alignment: Alignment.bottomCenter,
      width: MediaQuery.of(context).size.width,
      height: kBottomNavigationBarHeight, //get default height of the BottomNavigationBar
      decoration: BoxDecoration(
          color: Colors.yellow,
          border: Border.all(
              color: Colors.black, // Set border color
              width: 3.0),   // Set border width
          borderRadius: const BorderRadius.all(
              Radius.circular(10.0)), // Set rounded corner radius
          boxShadow: const [BoxShadow(blurRadius: 10,color: Colors.black,offset: Offset(1,3))] // Make rounded corner of border
      ),
      child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: const <Widget>[
            Image(
              image: AssetImage('images/company_logo.png'),
              height: kBottomNavigationBarHeight,
            ),
            SizedBox(
              width: 15,
            ),
            Text("DEVELOPED BY COMPANY_NAME",style: TextStyle(fontWeight: FontWeight.bold, fontFamily: 'Lobster'))
          ]
      )
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-07
      • 1970-01-01
      • 2020-07-07
      • 2022-12-18
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多