【问题标题】:flutter_BottomNavigationBar_Context: Found this candidate, but the arguments don't matchflutter_BottomNavigationBar_Context:找到了这个候选人,但参数不匹配
【发布时间】:2020-12-12 11:47:53
【问题描述】:

使用底部导航栏 我收到以下错误: 背景:找到了这个候选人,但论据不匹配。 const BottomNavigationBarItem({

我的代码是下一个:

bottomNavigationBar: BottomNavigationBar(
            items:[
              BottomNavigationBarItem(
                // ignore: deprecated_member_use
                title:Text('Hola'),
                icon:  (Icons.calendar_today),
              ),
              BottomNavigationBarItem(
                  icon (Icons.pie_chart_outlined),
                  title:Text('hola'),
              ),
              BottomNavigationBarItem(
                icon (Icons.supervised_user_circle),
                title:Text('hola'),
              ),
        ],
      ),

【问题讨论】:

  • 能否请您正确提供代码以及您调用bottomNavigationBar的代码块...
  • 尝试使用标签代替文本,看看是否能解决问题

标签: flutter navigationbar


【解决方案1】:

BottomNavigationBar 中没有图标的参数名称

像这样: BottomNavigationBarItem(icon: Icon(Icons.ac_unit), label: 'my label')

【讨论】:

    【解决方案2】:
    bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.business),
            label: 'Business',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.school),
            label: 'School',
          ),
        ],
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.amber[800],
        onTap: _onItemTapped,
      ),
    

    【讨论】:

      【解决方案3】:

      谢谢大家。它有两个缺陷:

      1. “title”参数已过时
      2. 我忘了放 Icon 类,一个很大的错误

      谢谢

      【讨论】:

        猜你喜欢
        • 2020-07-15
        • 2021-06-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-20
        • 1970-01-01
        相关资源
        最近更新 更多