CLMediaAttachWidget class
Widget riutilizzabile per gestire i media allegati a una risorsa.
Si passa il resourceIdentifier (es. l'id dell'evento o del prodotto) e i callback onUpload / onDelete per delegare le operazioni API al chiamante.
Esempio d'uso:
CLMediaAttachWidget(
resourceIdentifier: widget.eventId,
initialMediaList: vm.attachedMedia.map((m) => CLAttachedMedia(
id: m.id, url: m.url, originalName: m.originalName, path: m.path,
)).toList(),
onUpload: (media) async {
// upload via API, ritorna il nuovo media
final result = await myUploadCall(media);
return result != null
? CLAttachedMedia(id: result.id, url: result.url, ...)
: null;
},
onDelete: (id) async => await myDeleteCall(id),
onMediaChanged: () => vm.refreshMediaList(),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CLMediaAttachWidget
- Available extensions
Constructors
-
CLMediaAttachWidget({Key? key, required String resourceIdentifier, List<
CLAttachedMedia> initialMediaList = const [], Future<CLAttachedMedia?> onUpload(CLMedia media)?, Future<bool> onDelete(String id)?, VoidCallback? onMediaChanged, String emptyText = 'Nessun media allegato', List<String> allowedExtensions = const ['jpg', 'jpeg', 'png', 'gif', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'mp4', 'mov', 'avi']}) -
const
Properties
-
allowedExtensions
→ List<
String> -
Estensioni file consentite.
final
- emptyText → String
-
Testo mostrato quando non ci sono media.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
initialMediaList
→ List<
CLAttachedMedia> -
Lista iniziale di media già caricati.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onDelete
→ Future<
bool> Function(String id)? -
Callback per eliminare un media. Riceve l'
iddel media. Deve restituiretruese l'eliminazione va a buon fine.final - onMediaChanged → VoidCallback?
-
Callback dopo ogni modifica (upload o delete) per aggiornare il parent.
final
-
onUpload
→ Future<
CLAttachedMedia?> Function(CLMedia media)? -
Callback per caricare un file. Riceve il CLMedia dal picker.
Deve restituire un CLAttachedMedia se l'upload va a buon fine,
nullaltrimenti.final - resourceIdentifier → String
-
ID della risorsa a cui collegare i media.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
animateOnActionTrigger(
AnimationInfo animationInfo, {bool hasBeenTriggered = false}) → Widget -
Available on Widget, provided by the AnimatedWidgetExtension extension
-
animateOnPageLoad(
AnimationInfo animationInfo) → Widget -
Available on Widget, provided by the AnimatedWidgetExtension extension
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CLMediaAttachWidget> -
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, int wrapWidth = 65}) → 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