flutter 小众组件使用

132 阅读1分钟

垂直滑动选择组件ListWheelScrollView

///循环和不循环
ListWheelChildLoopingListDelegate、ListWheelChildListDelegate
ListWheelScrollView.useDelegate(
    itemExtent: 44,
    diameterRatio: 3,
    controller: _areaController,
    physics: const FixedExtentScrollPhysics(),
    perspective: 0.01,
    onSelectedItemChanged: (value) {
      selectIndex.value = value;
    },
    childDelegate: ListWheelChildListDelegate(
      children: List<Widget>.generate(
        cityList.length,
        (index) => Container(
            width: 375,
            height: 44,
            alignment: Alignment.center,
            child: Obx(() => Text(cityList[index],
                style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                    color: selectIndex.value == index
                        ? FXColor.newMainTextColor
                        : FXColor.newSecTextDartColor)))),
      ),
    ))

IgnorePointer

  • 用于隐藏子组件的点击事件,例如层叠结构中层级高的组件遮挡层级低组件点击事件,则可使用