FormItemMedia constructor

FormItemMedia({
  1. Key? key,
  2. TextEditingController? controller,
  3. required void onTap(
    1. void onUpdate(
      1. dynamic fileOrUrl
      )
    ),
  4. Color? color,
  5. String hintText = "",
  6. String errorText = "",
  7. bool allowEmpty = false,
  8. bool dense = false,
  9. double height = 200,
  10. List<String> videoExtensionList = const ["mp4", "ogv", "webm", "avi", "mpeg"],
  11. IconData icon = Icons.add_a_photo,
  12. void onSaved(
    1. String? value
    )?,
  13. String validator(
    1. String? value
    )?,
  14. String? initialURI,
  15. bool enabled = true,
  16. FormItemMediaType type = FormItemMediaType.both,
})

Form widget for uploading media (Image and Video).

FormItemMedia(
  constroller: useMemoizedTextEditingController(),
  onTap: (onUpdate){
    final media = await UIMediaDialog();
    onUpdate(media.path);
  },
  onSaved: (value){
    context["url"] = value;
  }
)

Implementation

FormItemMedia({
  Key? key,
  this.controller,
  required this.onTap,
  this.color,
  this.hintText = "",
  this.errorText = "",
  this.allowEmpty = false,
  this.dense = false,
  this.height = 200,
  this.videoExtensionList = const [
    "mp4",
    "ogv",
    "webm",
    "avi",
    "mpeg",
  ],
  this.icon = Icons.add_a_photo,
  void Function(String? value)? onSaved,
  String Function(String? value)? validator,
  String? initialURI,
  bool enabled = true,
  this.type = FormItemMediaType.both,
}) : super(
        key: key,
        builder: (state) {
          return const Empty();
        },
        onSaved: onSaved,
        validator: (value) {
          if (!allowEmpty && errorText.isNotEmpty && value.isEmpty) {
            return errorText;
          }
          return validator?.call(value);
        },
        initialValue: initialURI,
        enabled: enabled,
      );