让用户从CupertinoPickeronSelectedItemChanged结算选择值,然后将调用发送到API

问题描述

我正在使用面向iOS用户的CupertiNowidget,以滚动浏览列表并检查货币价格。但是,当发生滚动时, onselecteditemchanged 会针对列表中的每个值向API发送回调。我阅读了文档,但不知道该怎么办。如果有一个例子,这很令人高兴。

在文档中它被称为CupertinoPicker > onSelectedItemChanged property

可以在滚动和弹道猛冲期间调用。要仅在滚动结束时获取该值,请使用NotificationListener,侦听ScrollEndNotification并读取其FixedExtentMetrics。

 NotificationListener cupertinopickerList() {
    List<Text> textWidgetList = [];
    for (String curreny in currenciesList) {
      textWidgetList.add(
        Text(
          curreny,style: TextStyle(
            color: Colors.white,),);
    }
    return NotificationListener<ScrollNotification>(
      onNotification: (scrollNotification) {
        if (scrollNotification is ScrollEndNotification) {
          return true;
        } else {
          return false;
        }
      },child: Cupertinopicker(
        itemExtent: 30,scrollController: FixedExtentScrollController(initialItem: 19),onselecteditemchanged: (selectedindex) {
          selectedCurreny = currenciesList[selectedindex];
          updateUI(selectedCurreny);
          print(selectedCurreny);
        },children: textWidgetList,);
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)