FormMultiMedia<TValue> class

Form for submitting images and videos. Multiple media can be submitted.

All media is managed by FormMediaValue.

The path to the file asset and the asset type are passed to FormMediaValue as FormMediaType, so display and save accordingly.

Describe the process when the form is tapped in the onTap field. Normally, use image_picker or file_picker to display a dialog to select a file and return the media path to onUpdate.

Implement the part that actually displays the image based on the FormMediaValue in builder.

Specify a callback for deleting items in onRemove.

The entire design can be changed by specifying delegate. Specify FormMultiMediaInlineDelegate to display a list of media inline. Specify FormMultiMediaListTileDelegate to display a list of media in a vertical list view.

Place under the Form that gave FormController.key, or pass FormController to form.

When FormController is passed to form, onSaved must also be passed together. The contents of onSaved will be used to save the data.

Enter the initial value given by FormController.value in initialValue.

Each time the content is changed, onChanged is executed.

When FormController.validate is executed, validation and data saving are performed.

Only when emptyErrorText is specified, emptyErrorText will be displayed as an error if the item is not specified.

Other error checking is performed by specifying validator. If a string other than Null is returned in the callback, the string is displayed as an error statement. If Null is returned, it is processed as no error.

Deactivated if enabled is false or readOnly is true.

If maxLength is specified, no more items can be added.

画像や映像を投稿するためのフォーム。複数のメディアを投稿することが可能です。

メディアはすべてFormMediaValueで管理されます。

FormMediaValueにファイルアセットへのパスとアセットのタイプがFormMediaTypeで渡されるのでそれに応じて表示や保存を行ってください。

onTapにフォームがタップされた場合の処理を記述します。通常はimage_pickerfile_pickerを用いてファイルを選択するダイアログを表示しメディアのパスをonUpdateに返すようにします。

builderFormMediaValueを元に実際に画像を表示する部分を実装してください。

onRemoveに項目の削除時のコールバックを指定します。

delegateを指定することで、全体のデザインを変更することが可能です。 FormMultiMediaInlineDelegateを指定するとインライン内でメディアの一覧が表示されるようになります。FormMultiMediaListTileDelegateを指定すると縦にリスト表示でメディアの一覧が表示されるようになります。

FormController.keyを与えたForm配下に配置、もしくはformFormControllerを渡します。

formFormControllerを渡した場合、一緒にonSavedも渡してください。データの保存はonSavedの内容が実行されます。

initialValueFormController.valueから与えられた初期値を入力します。

内容が変更される度onChangedが実行されます。

FormController.validateが実行された場合、バリデーションとデータの保存を行ないます。

emptyErrorTextが指定されている時に限り、項目が指定されていない場合emptyErrorTextがエラーとして表示されます。

それ以外のエラーチェックはvalidatorを指定することで行ないます。 コールバック内でNull以外を返すようにするとその文字列がエラー文として表示されます。Nullの場合はエラーなしとして処理されます。

enabledfalseになる、もしくはreadOnlytrueになっている場合は非有効化されます。

maxLengthが指定されている場合、それ以上項目を増やすことができなくなります。

Inheritance
Available Extensions
Annotations

Constructors

FormMultiMedia({Key? key, FormController<TValue>? form, FormStyle? style, void onRemove(FormMediaValue value)?, int? maxLength, List<FormMediaValue>? initialValue, String? emptyErrorText, bool readOnly = false, required Widget builder(BuildContext context, FormMediaValue value), required void onTap(FormMultiMediaRef ref), void onChanged(List<FormMediaValue> value)?, TValue onSaved(List<FormMediaValue> value)?, String validator(List<FormMediaValue> value)?, FormMultiMediaDelegate delegate = const FormMultiMediaInlineDelegate(), bool enabled = true, bool keepAlive = true})
Form for submitting images and videos. Multiple media can be submitted.

Properties

autovalidateMode AutovalidateMode
Used to enable/disable this form field auto validation and update its error text.
finalinherited
builder FormFieldBuilder<List<FormMediaValue>>
Function that returns the widget representing this form field. It is passed the form field state as input, containing the current value and validation state of this field.
finalinherited
delegate FormMultiMediaDelegate
A delegate to determine the design of the form.
final
emptyErrorText String?
Error text. Only displayed if no characters are entered.
final
enabled bool
Whether the form is able to receive user input.
finalinherited
form FormController<TValue>?
Context for forms.
final
hashCode int
The hash code for this object.
no setterinherited
initialValue List<FormMediaValue>?
An optional value to initialize the form field to, or null otherwise.
finalinherited
keepAlive bool
If placed in a list, whether or not it should not be discarded on scrolling.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxLength int?
If specified, no more items can be added.
final
onChanged → (void Function(List<FormMediaValue> value)?)
Callback to be executed each time the value is changed.
final
onRemove → (void Function(FormMediaValue value)?)
Callback when deleting an item.
final
onSaved FormFieldSetter<List<FormMediaValue>>?
An optional method to call with the final value when the form is saved via FormState.save.
finalinherited
onTap → void Function(FormMultiMediaRef ref)
Describe what to do when the form is tapped.
final
readOnly bool
If this is true, the form cannot be filled out and changed from its initial value.
final
restorationId String?
Restoration ID to save and restore the state of the form field.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
style FormStyle?
Form Style.
final
validator FormFieldValidator<List<FormMediaValue>>?
An optional method that validates an input. Returns an error string to display if the input is invalid, or null otherwise.
finalinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _FormMultiMediaState<TValue>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited