flutter - 启动应用程序时初始化 CupertinoPicker (flutter)
问题描述
当我开始在我的设备上调试应用程序时,CupertinoPicker 运行良好,但是当我重新启动应用程序(而不是调试)时,即使列表已成功初始化,Cupertino 也没有显示任何内容。SharedPrefences 在 initState 函数中初始化的列表。可能是什么原因?
库比蒂诺代码:
Widget buildChosenExeOrRestPicker() => SizedBox(
height: 170,
child: CupertinoPicker(
scrollController: ctrl,
magnification: 1.3,
useMagnifier: true,
itemExtent: 45,
diameterRatio: 1.1,
looping: false,
onSelectedItemChanged: (index) {
setState(() {
this.indexOfRes = index;
});
},
selectionOverlay: CupertinoPickerDefaultSelectionOverlay(
background: (pickerExeOrRest.length > 0)
? Colors.cyanAccent.withOpacity(0.12)
: Colors.transparent,
),
children: modelBuilder<PickerExeOrRest>(
pickerExeOrRest,
(index, value) {
final isSelected = this.indexOfRes == index;
final color = isSelected ? Colors.pink : Colors.black;
return Center(
child: Text(
'${value.time + ', ' + value.name}',
style: TextStyle(
color: color.withOpacity(opacityCupertino), fontSize: 24),
),
);
},
),
),
);
解决方案
推荐阅读
- python - image_dataset_from_directory() 如何对数字类名的预测进行排序?
- ios - ionic ios build 在 ios 上工作时出错
- asp.net-core - Blazor webassembly 存储 auth0 机密
- android - 如何保存活动状态?
- javascript - 指定的值不符合要求的格式“yyyy-MM-dd”。Vue.js
- javascript - 当用户滚动 div 时隐藏 div 在 JavaScript 中不起作用
- elasticsearch - ElasticSearch - 布尔查询过滤器问题
- angularjs - AngularJS 中的 $state.go 在子菜单上不起作用
- node.js - 在没有标志 --runInBand 的情况下运行测试时出现开玩笑问题 - 我的测试失败
- python-3.x - 将字符串转换为时间