我有一个脚手架,当我在不同的手机上测试时,它总是给我溢出错误.我在代码中只用了mediaquery.of(context).size.height
一次,我得到了40.392的溢出错误,这没有任何意义,因为我在声明高度时从来没有使用小数
Scaffold(
backgroundColor: Colors.black,
appBar: PreferredSize(
preferredSize: const Size.fromHeight(50),
child: AppBar(
elevation: 0,
iconTheme: const IconThemeData(color: Colors.blue),
backgroundColor: mode.background1,
actions: actionList(),
),
),
body: Container(
height: MediaQuery.of(context).size.height - 104,
child: Column(
children: [
Container(
//overflow error exists right here
height: MediaQuery.of(context).size.height - 107,
child: getWid(_selectedindex)),
Container(
height: 3,
child: Row(
children: [
mydivider(0),
mydivider(1),
mydivider(2),
mydivider(3),
],
),
)
],
),
),
bottomNavigationBar: Theme(
data: Theme.of(context).copyWith(
brightness: Brightness.dark,
canvasColor: mode.canvasColor,
primaryColor: const Color.fromARGB(255, 45, 124, 243),
textTheme: Theme.of(context)
.textTheme
.copyWith(bodySmall: const TextStyle(color: Colors.grey))),
child: SizedBox(
height: 54,
child: BottomNavigationBar(
onTap: (int index) {
setState(() {
_selectedindex = index;
});
},
currentIndex: _selectedindex,
type: BottomNavigationBarType.fixed,
selectedItemColor: Colors.blue,
unselectedItemColor: Colors.grey,
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.list),
label: 'List',
),
BottomNavigationBarItem(
icon: Icon(Icons.local_grocery_store),
label: 'Checkout',
),
BottomNavigationBarItem(
icon: Icon(Icons.history),
label: 'Transactions',
),
BottomNavigationBarItem(
icon: Icon(Icons.settings_outlined),
label: 'Settings',
)
]),
),
),
)
很明显,我给了所有的小工具高度.我认为唯一合乎逻辑的解释是在这款手机上构建窗口小部件时出现了错误,但我不知道如何处理.另外,我以前在这款手机上测试过很多应用程序. 我感谢你的帮助