TTableHeader<T, K>.toggle constructor
TTableHeader<T, K>.toggle (
- String text,
- bool? get(
- T
- void set(
- T,
- bool
- int? flex,
- double? minWidth,
- double? maxWidth,
- Alignment? alignment = Alignment.center,
- bool disabled = false,
- bool isDisabled(
- T data
- String? key,
- TFilterType? filterType = TFilterType.boolean,
- bool filterable = true,
- List<
TFilterOperator> ? filterOperators, - List? filterItems,
- TFilterDef<
T> ? filterDef, - Color? color,
- Color? inactiveColor,
- double widthEstimator(
- T data
- bool flattenOnMobile = false,
- String mobileKeyPrefixBuilder()?,
- List<
TKeyValue> keyValuesBuilder(- T data
Creates a header for displaying and editing boolean values using TSwitch.
Implementation
TTableHeader.toggle(
this.text,
bool? Function(T) get,
void Function(T, bool)? set, {
this.flex,
this.minWidth,
this.maxWidth,
this.alignment = Alignment.center,
bool disabled = false,
bool Function(T data)? isDisabled,
this.key,
this.filterType = TFilterType.boolean,
this.filterable = true,
this.filterOperators,
this.filterItems,
this.filterDef,
Color? color,
Color? inactiveColor,
double Function(T data)? widthEstimator,
this.flattenOnMobile = false,
this.mobileKeyPrefixBuilder,
this.keyValuesBuilder,
}) : map = get,
widthEstimator = widthEstimator ?? ((_) => 48.0),
builder = ((ctx, item, __) {
final isDense = TTableScope.maybeOf(ctx)?.dense ?? false;
final val = get(item.data) ?? false;
final isOff = disabled || (isDisabled?.call(item.data) ?? false);
return TSwitch(
value: val,
disabled: isOff,
size: isDense ? TInputSize.xs : TInputSize.sm,
color: color,
inactiveColor: inactiveColor,
onValueChanged: isOff || set == null ? null : (newVal) => set(item.data, newVal ?? false),
);
});