我正在尝试在 Flexible 中使用 ListView.builder。当我将其更改为滚动方向时,它在滚动方向上工作正常:Axis.vertical:Axis.horizontal。它不工作
List modeData = [
{'modeName': 'VAN', 'modeTime': '3 min', 'modeIcon': Icons.android },
{'modeName': 'VAN', 'modeTime': '3 min', 'modeIcon': Icons.android },
];
callback(data) {}
int _selectedIndex = 0;
_onSelected ( int index ) {
setState(() => _selectedIndex = index);
}
@override
Widget build(BuildContext context) {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: modeData.length,
itemBuilder: (context, index) => Container(
child: ListTile(
onTap: () => _onSelected(index),
// title: TravelMode(modeName, modeIcon, modeTime, isSelected),
title: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text(modeData[index]['modeTime']),
Container(
decoration: new BoxDecoration(enter code here
color: _selectedIndex != null && _selectedIndex ==
index ? Colors.blue : null,
borderRadius: new BorderRadius.all(const
Radius.circular(40.0))),
child: IconButton(
icon: Icon(modeData[index]['modeIcon']),
color: Colors.black38,
),
),
Text(modeData[index]['modeName'])
],
),
),
)
);
}
}
Flexible(
flex: 2,
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child:
TravelModesList()),],),
),
我在此灵活输入图像描述中调用它,
试图实现 Ola Cab 中显示的车辆列表enter code here