renderProperty method
Iterable<Widget>
renderProperty(
- BuildContext context,
- IMetaFormContext metaForm,
- HandledPaths paths,
- SunnyFormFieldState<
IImageContent> state, { - Key? key,
override
Renders a widget (or null) for a provided HandledPaths (see acceptProperties)
Implementation
Iterable<Widget> renderProperty(
BuildContext context,
IMetaFormContext metaForm,
HandledPaths paths,
SunnyFormFieldState<IImageContent> state,
{Key? key}) {
final fullPath = paths.fullPath<IImageContent>();
final form = context.form();
final initialValue = form.path(fullPath);
final readyCheck = state.form?.requestReadyCheck(fullPath);
return [
ImageUrlControl(
size: 50,
initialValue: initialValue?.imageUrl?.toUri(),
type: 'picture',
readyCheck: readyCheck,
allowThirdParty: true,
onUploaded: (upload) {
SunnyHud.info(context, "Uploaded Successfully", duration: 1500.ms);
final imageContent = state.value ??
IImageContent.of(
dismissible: false,
delivery: IContentDelivery.inline_,
imageUrl: null,
);
imageContent.imageUrl = upload.toString();
state.updateValue(imageContent, AttributeSource.control);
},
onFileChanged: (file) {
// ignore: missing_required_param, unused_local_variable
final imageContent = state.value ??
IImageContent.of(
dismissible: false,
delivery: IContentDelivery.inline_,
imageUrl: null,
);
imageContent.selectedFile = file;
},
onError: (response, stack) {
SunnyHud.error(context, "Problem uploading", duration: twoSeconds);
log.warning("Error uploading: $response", response, stack);
state.error = ValidationError.ofString(
fullPath,
"Problem uploading",
debugMessage: "$response",
);
},
)
];
}