TfChoiceSetting<T extends Object> class

单选设置项:从 options 中选一个值保存。

选项不超过 inlineLimit 个时直接显示为分段选择器;更多时显示当前值, 点击后弹出对话框选择。偏好值是枚举时,用 TfChoiceSetting.enumeration。

const TfChoiceSetting<int>(
  key: AppKeys.syncInterval,
  title: '同步间隔',
  options: [TfChoice(15, '15 分钟'), TfChoice(60, '1 小时'), TfChoice(1440, '每天')],
)
Inheritance

Constructors

TfChoiceSetting({required TfPreferenceKey<T> key, required List<TfChoice<T>> options, required String title, String? subtitle, IconData? icon, int inlineLimit = 3})
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
icon → IconData?
左侧图标(可选)。
finalinherited
inlineLimit → int
选项数不超过它时直接显示分段选择器,否则弹出对话框。
final
key → TfPreferenceKey<T>
保存所选值的偏好。
final
leading → Widget?
由 icon 生成的左侧图标。
no setterinherited
options → List<TfChoice<T>>
全部选项。
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
subtitle → String?
副标题(可选)。
finalinherited
subtitleWidget → Widget?
由 subtitle 生成的副标题。
no setterinherited
title → String
标题。
finalinherited

Methods

build(BuildContext context, TfPreferencesController preferences) → Widget
构建这一行的界面,会被放在 TfSection 中。
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

enumeration<E extends Enum>(TfEnumPreference<E> preference, {required String title, required Map<E, String> labels, Map<E, IconData> icons = const {}, String? subtitle, IconData? icon}) → TfChoiceSetting<String>
枚举类型的单选:labels 中没有列出的枚举值不会显示。