如何更改 Flutter 中 `BottomNavigationBar()` 中项目之间的间距?

Phi*_*aro 6 dart flutter bottomnavigationview

1.我希望我能做什么

到目前为止,我的BottomNavigationBar看起来还不错(而且很简单),但是,考虑到我里面只有 2 个项目,我想让它们靠近一点(也许在右边),这样它们更容易到达。我怎么做?是否有房产可以完成这项工作?也许在BottomNavigationBar主题里面?

2. 一个片段

这是现在的样子:

bottomNavigationBar: BottomNavigationBar(
  items: <BottomNavigationBarItem>[
    BottomNavigationBarItem(
      icon: Icon(Icons.account_circle),
      title: Text('Personal Data'),
    ),
    BottomNavigationBarItem(
      icon: Icon(Icons.payment),
      title: Text('Contracts'),
    ),
  ],
  currentIndex: _selectedIndex,
  selectedItemColor: Colors.orange,
  onTap: _onItemTapped,
),
Run Code Online (Sandbox Code Playgroud)

Adr*_*ray 2

在检查其源代码后,BottomNavigationBar由于此处的这一行,这似乎不容易实现:

Widget _createContainer(List<Widget> tiles) {
  return DefaultTextStyle.merge(
    overflow: TextOverflow.ellipsis,
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: tiles,
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)

它位于类中的私有函数中。这意味着为了更改包含图块mainAxisAlignment的属性,Row您必须重新创建整个类。