getWidgets method

List<Widget> getWidgets()

Get a list of widgets corresponding to form attributes.

The getWidgets function is used to generate a list of widgets that correspond to the form attributes. It iterates through the attributes list, and for each attribute, it generates a widget based on its type (either FormifyAttribute or FormifyRowAttribute). For FormifyAttribute, it uses the _formWidget function to create the widget. For FormifyRowAttribute, it generates a Row widget containing a list of child widgets, each created using _listFormWidget. The function also inserts separator widgets between attribute widgets.

Returns: A list of widgets representing the form attributes and separators.

Implementation

List<Widget> getWidgets() {
  return attributes
      .map((att) {
        if (att is FormifyAttribute) {
          return _formWidget(att);
        } else if (att is FormifyRowAttribute) {
          return Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: _listFormWidget(att)
                .map((e) => Expanded(child: e))
                .toList()
                .addInBetween(_separatorHorizontalWidget()),
          );
        }
        return const SizedBox();
      })
      .toList()
      .addInBetween(_separatorWidget());
}