我是 Flutter 开发的新手,我正在尝试 CupertinoPicker
里面showCupertinoModalPopup
通过点击 CupertinoButton
触发.
选择Provinsi (Province)
后, 我可以重新选择 Province
通过再次单击按钮,但它应该是我确实选择的项目。
这是我的代码
showCupertinoModalPopup(
context: context,
builder: (_) {
return new SizedBox(
height: MediaQuery.of(context).size.height / 2,
child: new CupertinoPicker(
magnification: 1.2,
useMagnifier: true,
itemExtent: 32.0,
onSelectedItemChanged: (i) => setState(() => _chosenProvince = listProvince[i]),
children: r != null && listProvince != null ? listProvince.map((prov) {
return new Padding(
padding: const EdgeInsets.all(4.0),
child: new Text(
prov.name,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: new TextStyle(
fontSize: 20.0,
),
),
);
}).toList(): [],),);});
有没有initialValue
或 CupertinoPicker
的东西设置为?
最佳答案
您可以使用 FixedExtentScrollController
来设置 initialValue。引用this
关于flutter - 设置选定的初始 CupertinoPicker 选定索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52385149/