import 'dart:io'; import 'package:component_library/component_library.dart'; import 'package:reactive_forms/reactive_forms.dart'; import 'error_messages.dart'; class ReactiveInputFile extends ReactiveFormField, List> { ReactiveInputFile({ required String name, allowMultiple = false, allowedExtensions = const ['jpg', 'jpeg', 'png', 'gif'], uploadButtonLabel, guidanceLabel, descriptionLabel, }) : super( formControlName: name, builder: (field) { return InputFile( files: field.value, allowMultiple: allowMultiple, descriptionLabel: descriptionLabel, guidanceLabel: guidanceLabel, uploadButtonLabel: uploadButtonLabel, allowedExtensions: allowedExtensions, errorMessage: ErrorMessages.getUiErrorMessage( control: field.control, label: '', widgetCustomMessages: {'required': 'Foto harus diisi'}, ), isTouched: field.control.touched, isError: field.control.hasErrors, onChange: (files) { field.didChange(files); }, ); }, ); @override ReactiveFormFieldState, List> createState() { return ReactiveFormFieldState, List>(); } }