在我的報紙應用程式中,最左邊的底部導航欄專案總是顯示在比其他專案更高的位置,它沒有對齊。

您可以看到該bookmark圖示未與其他圖示對齊。事實上,如果我將任何其他圖示放在第一個位置,該圖示就會顯示在更高的位置。無論我在那里添加什么圖示,問題都在于第一個專案。
代碼 BottomNavigationBar
import 'package:flutter/material.dart';
import 'package:news_app/main.dart';
BottomNavigationBar getBottomNavBar(themeProvider, context, appbarScrollController, refresh) {
return BottomNavigationBar(
elevation: 3,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.bookmark,
color: themeProvider.themeMode == ThemeMode.light ? Colors.black : Colors.white,
),
label: ""
),
BottomNavigationBarItem(
icon: Icon(
Icons.home_sharp,
color: themeProvider.themeMode == ThemeMode.light ? Colors.black : Colors.white,
),
label: ""
),
BottomNavigationBarItem(
icon: Icon(
Icons.subject,
color: themeProvider.themeMode == ThemeMode.light ? Colors.black : Colors.white,
),
label: ""
),
BottomNavigationBarItem(
icon: Icon(
Icons.video_collection,
color: themeProvider.themeMode == ThemeMode.light ? Colors.black : Colors.white,
),
label: ""
),
BottomNavigationBarItem(
icon: Icon(
Icons.more_horiz,
color: themeProvider.themeMode == ThemeMode.light ? Colors.black : Colors.white,
),
label: ""
),
],
onTap: (index) {
},
);
}
我保留了所有labels空白,因為我不需要它們。在所有出現此對齊問題的螢屏中,它看起來都是一樣的。
uj5u.com熱心網友回復:
根據檔案:
如果未指定 type,則當少于四個專案時,它會自動設定為 BottomNavigationBarType.fixed,否則將設定為 BottomNavigationBarType.shifting。
并且由于您有 3 個以上的專案,因此型別更改為 BottomNavigationBarType.shifting將所選專案略微向上移動。
試試這個:
BottomNavigationBar(
type: BottomNavigationBarType.fixed,
...
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/419784.html
標籤:
