list - 未在颤动中显示年份下拉数据
问题描述
这是我的列表,用于显示字符串类型列表中的数据-
List<Widget> _getYearList() {
List<Widget> list = List<Widget>();
for (int index = 0; index < 30; index++) {
list.add(Container(
alignment: Alignment.center,
child: Text(
UtilString.years[index],
//'$index',
style: TextStyle(fontSize: 16),
),
));
}
return list;
}
这是设计视图-
SizedBox(width: 8),
Text(
'${UtilString.year} : ',
style: TextStyle(
fontSize: 16,
color: Colors.grey[700],
),
),
Container(
height: 100,
width: 52,
child: CupertinoPicker(
squeeze: 1.3,
itemExtent: 30,
backgroundColor: Colors.white,
children: _getYearList(),
scrollController: FixedExtentScrollController(
initialItem: _year - 1,
),
onSelectedItemChanged: (item) {
setState(() {
_year = item + 1;
});
},
),
),
],
),
定义数据
static final List years = <String>['1990', '1991', '1992', '1993 till 2020];
解决方案
推荐阅读
- pandas - 使用 groupby() 从后面进行累积乘法
- python - 为什么以不同的方式生成数组会导致代码不同部分的大量加速?
- javascript - ES8 和 ES9 中的 jshint 指的是什么?
- r - 错误 1:从 JavaScript 动态生成 Web 抓取时下标越界
- openssl - 在 OpenSSL 命令行工具中为自定义扩展创建自己的 ASN.1 模块
- jquery - 将导航栏品牌和链接与 Bootstrap 4 中的页面内容对齐
- node.js - 如何通过 nodejs express 应用程序调用 API 获取 png 图像
- javascript - Android 版 Chrome 中文本输入的奇怪行为
- java - 如果我在嵌入式 tomcat 上运行我的 Rest API 并且 IDE 已关闭,它从哪里运行?
- laravel - Laravel-echo-server 码头化问题