build<TValue> method
Widget
build<TValue>(
- BuildContext context,
- FormMultiMediaRef<
TValue> ref, - FormMultiMedia<
TValue> widget, - 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
.
全体をビルドします。
context
にBuildContext、widget
にビルドされている元のWidget、values
に現在の値を渡します。
onUpdate
に更新時のコールバックとonRemove
に削除時のコールバックが渡されます。
Implementation
@override
Widget build<TValue>(
BuildContext context,
FormMultiMediaRef<TValue> ref,
FormMultiMedia<TValue> widget,
List<FormMediaValue> values,
) {
return FormStyleContainer(
style: widget.style,
labelText: widget.labelText,
alignment: Alignment.centerLeft,
padding: widget.style?.padding ??
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: SizedBox(
height: widget.style?.height ?? kFormMultiMediaInlineHeight,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
if (widget.maxLength == null || widget.maxLength! > values.length)
Container(
width: widget.style?.width ?? kFormMultiMediaInlineHeight,
height: widget.style?.height ?? kFormMultiMediaInlineHeight,
margin: const EdgeInsets.only(right: 8),
child: OutlinedButton(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
side: BorderSide(
color: widget.style?.color ??
Theme.of(context).dividerColor,
width: widget.style?.borderWidth ?? 2,
),
borderRadius: BorderRadius.circular(4.0),
)),
onPressed: widget.readOnly || !widget.enabled
? null
: () {
widget.onTap.call(ref);
},
child: Icon(
addIcon,
color:
widget.style?.color ?? Theme.of(context).dividerColor,
size: (widget.style?.height ??
kFormMultiMediaInlineHeight) /
3.0,
),
),
),
...values.mapAndRemoveEmpty(
(value) {
return Padding(
padding: const EdgeInsets.only(right: 8),
child: _buildItem(
context,
widget,
value,
widget._builder,
widget.readOnly || !widget.enabled ? null : ref.update,
widget.readOnly || !widget.enabled
? null
: () => ref.delete(value),
),
);
},
),
],
),
),
),
);
}