这是我的底部导航栏,现在我想显示底部导航栏,但最初没有选择它的任何项目。当我将 _selectedIndex 设置为 null 时,我收到错误。有什么办法可以实现这个目标吗?
int _selectedIndex = 0;
BottomNavigationBar(
backgroundColor: Colors.blueAccent,
unselectedItemColor: Colors.white,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.add),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.camera_alt),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text(''),
),
],
currentIndex: _selectedIndex,
onTap: (index) {
setState(() {
_selectedIndex = index;
});
},
);
Run Code Online (Sandbox Code Playgroud) 我想根据屏幕尺寸提供填充或边距。
下面是具有相同填充的两个不同尺寸屏幕的代码和图像。
这是我的代码:
Padding(
padding: const EdgeInsets.only(top: 160, left: 90, bottom: 20),
child: Row(
children: <Widget>[
Image.asset(
'assets/logo.png',
height: 70,
width: 70,
),
Text(
' Whatsapp',
style: TextStyle(
fontSize: 26,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
),
Run Code Online (Sandbox Code Playgroud)
我的真实设备

Android Studio 模拟器

我有这个字符串列表:
final List<String> details;
Run Code Online (Sandbox Code Playgroud)
我想使用文本小部件打印列表中的字符串,这就是我所做的:
List<Product> products = [details: [
'7 ounces',
'Pack of 200 grams',
'Golden roasted' 'Nicely packed in its original Nescafe factory'
],],
Run Code Online (Sandbox Code Playgroud)
使用的文本小部件:
Text( products.details[0], ),
Run Code Online (Sandbox Code Playgroud)
这仅打印索引 0 处的字符串。
有人可以帮忙吗?