Flutter中如何以编程方式更新CupertinoSlidingSegmentedControl的值?
CupertinoSlidingSegmentedControl 编程式更新选中值的问题
CupertinoSlidingSegmentedControl 并未提供编程式更新选中值的官方方法。目前唯一的变通方案是更新组件的Key(例如使用ValueKey),但这种操作会导致滑动过渡效果被禁用,体验并不理想。
组件代码示例:
CupertinoSlidingSegmentedControl( padding: EdgeInsets.zero, thumbColor: ColorAssets.green, groupValue: selected, onValueChanged: (value) { }, children: widget.children.map( (key, value) => MapEntry( key, Container( height: constraints.maxHeight, alignment: Alignment.center, padding: const EdgeInsets.only(bottom: 2), child: Text( value, ), ) ), ), )
内容的提问来源于stack exchange,提问作者Abrar Malekji
相关产品推荐
相关产品推荐

