代码之家  ›  专栏  ›  技术社区  ›  Ampersanda

设置选定的初始CupertinoPicker选定索引

  •  0
  • Ampersanda  · 技术社区  · 6 年前

    我是新来的颤振发展,我正在努力 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 或是什么 铜试剂 设置为?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Dinesh Balasubramanian    6 年前

    你可以使用 FixedExtentScrollController 设置 初始值 . 参考 this