build<TValue> method

  1. @override
Widget build<TValue>(
  1. BuildContext context,
  2. FormMultiMediaRef<TValue> ref,
  3. FormMultiMedia<TValue> widget,
  4. List<FormMediaValue> values,
)
override

Build the whole thing.

Pass context the BuildContext, widget the original widget being built, and values the current values.

The callback for updating is passed to onUpdate and the callback for deleting is passed to onRemove.

全体をビルドします。

contextBuildContextwidgetにビルドされている元のWidget、valuesに現在の値を渡します。

onUpdateに更新時のコールバックとonRemoveに削除時のコールバックが渡されます。

Implementation

@override
Widget build<TValue>(
  BuildContext context,
  FormMultiMediaRef<TValue> ref,
  FormMultiMedia<TValue> widget,
  List<FormMediaValue> values,
) {
  return Padding(
    padding: widget.style?.padding ??
        const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.start,
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        ...values.map((value) {
          return _buildItem(
            context,
            value,
            widget._builder,
            widget.readOnly || !widget.enabled ? null : ref.update,
            widget.readOnly || !widget.enabled
                ? null
                : () => ref.delete(value),
          );
        }),
        if (widget.maxLength == null || widget.maxLength! > values.length)
          ListTile(
            onTap: widget.readOnly || !widget.enabled
                ? null
                : () {
                    widget.onTap.call(ref);
                  },
            title: addLabel,
            trailing: Icon(addIcon),
          ),
      ],
    ),
  );
}