17

私はフラッター開発の初心者です。クリックしてトリガーされたCupertinoPicker内部にしようとしています。showCupertinoModalPopupCupertinoButton

を選択した後、ボタンをもう一度クリックして を選択し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か?

4

2 に答える 2

31

を使用してinitialValueFixedExtentScrollControllerを設定できます。これを参照

于 2018-09-18T13:31:06.127 に答える