|
|
|
|
@ -322,6 +322,7 @@ class AttachmentPicker extends StatefulWidget {
|
|
|
|
|
final Function(List<GenericAttachmentModel>)? onChange;
|
|
|
|
|
final bool showAsGrid;
|
|
|
|
|
final bool showAsListView;
|
|
|
|
|
final bool pickMultiple;
|
|
|
|
|
Lookup? documentType;
|
|
|
|
|
|
|
|
|
|
AttachmentPicker(
|
|
|
|
|
@ -337,6 +338,7 @@ class AttachmentPicker extends StatefulWidget {
|
|
|
|
|
this.documentType,
|
|
|
|
|
this.showAsGrid = false,
|
|
|
|
|
this.showAsListView = false,
|
|
|
|
|
this.pickMultiple = false,
|
|
|
|
|
this.buttonColor})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@ -348,7 +350,8 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,spacing: 12,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
spacing: 12,
|
|
|
|
|
children: [
|
|
|
|
|
AppDashedButton(
|
|
|
|
|
title: widget.label,
|
|
|
|
|
@ -465,16 +468,21 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
)) as ImageSource;
|
|
|
|
|
|
|
|
|
|
final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
// if(widget.pickMultiple) {
|
|
|
|
|
final pickedFile12 = await ImagePicker().pickMultiImage(imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
|
|
|
File fileImage = File(pickedFile.path);
|
|
|
|
|
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentTypeId: widget.documentType));
|
|
|
|
|
if (widget.onChange != null) {
|
|
|
|
|
widget.onChange!(widget.attachment);
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
// // }
|
|
|
|
|
//
|
|
|
|
|
// final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
//
|
|
|
|
|
// if (pickedFile != null) {
|
|
|
|
|
// File fileImage = File(pickedFile.path);
|
|
|
|
|
// widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentTypeId: widget.documentType));
|
|
|
|
|
// if (widget.onChange != null) {
|
|
|
|
|
// widget.onChange!(widget.attachment);
|
|
|
|
|
// }
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget gridItem(IconData iconData, String title) {
|
|
|
|
|
@ -632,6 +640,20 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
// );
|
|
|
|
|
if (source == null) return;
|
|
|
|
|
|
|
|
|
|
if (widget.pickMultiple && source == ImageSource.gallery) {
|
|
|
|
|
final pickedFiles = await ImagePicker().pickMultiImage(imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
if (pickedFiles.isNotEmpty) {
|
|
|
|
|
pickedFiles.forEach((pickedFile) {
|
|
|
|
|
File fileImage = File(pickedFile.path);
|
|
|
|
|
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path, documentTypeId: widget.documentType));
|
|
|
|
|
});
|
|
|
|
|
if (widget.onChange != null) {
|
|
|
|
|
widget.onChange!(widget.attachment);
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
|
|
|
|