用途:在 Flutter 应用中实现单选按钮组或单选选项,也可作为表单字段使用。
主要能力:ShadRadioGroup<T> 是一组单选按钮,至多选中一项;items 接收一组 ShadRadio<T>,每个包含 value 与 label。表单场景使用 ShadRadioGroupFormField<T>,放在 ShadForm 内,配置 id、label、items 与 validator。
使用方式(独立组件):ShadRadioGroup<String>(items: [ShadRadio(label: Text('Default'), value: 'default'), ShadRadio(label: Text('Comfortable'), value: 'comfortable'), ShadRadio(label: Text('Nothing'), value: 'nothing')])。
使用方式(表字段):定义枚举后传入 ShadRadioGroupFormField<NotifyAbout>(label: const Text('Notify me about'), items: NotifyAbout.values.map((e) => ShadRadio(value: e, label: Text(e.message))), validator: (v) { if (v == null) return 'You need to select a notification type.'; return null; })。
适用场景:设置面板、偏好或通知方式选择、任何需要从多个互斥选项中选一个的界面。
限制:资料未提供平台、安装方式、依赖版本、收费与价格等信息,均暂未提供。