toWidget method

  1. @override
Widget toWidget(
  1. BuildContext context,
  2. String group,
  3. double? value
)
inherited

Builds the current field into a Widget to be used for input in the side panel.

Implementation

@override
Widget toWidget(BuildContext context, String group, T? value) {
  final defaultValue = (T == int ? 0 : 0.0) as T;

  return Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Expanded(
        flex: 8,
        child: Slider(
          value: (value ?? initialValue)?.toDouble() ?? 0,
          min: min.toDouble(),
          max: max.toDouble(),
          label: codec.toParam(value ?? initialValue ?? defaultValue),
          divisions: divisions,
          onChanged: (value) {
            return updateField(
              context,
              group,
              codec.toValue(value.toString())!,
            );
          },
        ),
      ),
      Expanded(
        child: Text(
          codec.toParam(value ?? initialValue ?? defaultValue),
          textAlign: TextAlign.end,
          maxLines: 1,
        ),
      ),
    ],
  );
}