build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the user interface represented by this widget.

Implementation

@override
Widget build(BuildContext context) {
  final Widget childWidget;
  if (widget.child != null) {
    childWidget = widget.child!;
  } else {
    final items = <Widget>[];
    for (final field in widget.fields) {
      final height = field.getPreferredHeight();
      final wrappedField = LeftBorder(
        char: field.focused ? '│' : ' ',
        style: const Style(
          foreground: CharmColors.charple,
          modifiers: Modifier.bold,
        ),
        padding: const EdgeInsets.only(left: 1),
        borderHeight: (height - 1).clamp(0, height),
        child: field,
      );
      items.add(SizedBox(height: height, child: wrappedField));
    }
    childWidget = Column(items);
  }

  return FormScope(formState: this, child: childWidget);
}