|
|
|
|
@ -339,7 +339,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
for (var path in result.paths) {
|
|
|
|
|
widget.attachment.add(GenericAttachmentModel(id: 0,name: File(path!).path));
|
|
|
|
|
widget.attachment.add(GenericAttachmentModel(id: 0, name: File(path!).path));
|
|
|
|
|
}
|
|
|
|
|
if (widget.onChange != null) {
|
|
|
|
|
widget.onChange!(widget.attachment);
|
|
|
|
|
@ -347,8 +347,12 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void showFileSourceSheet() async {
|
|
|
|
|
if (widget.attachment.length >= 5) {
|
|
|
|
|
Fluttertoast.showToast(msg: context.translation.maxImagesNumberIs5);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ImageSource source = (await showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
@ -386,7 +390,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
|
|
|
File fileImage = File(pickedFile.path);
|
|
|
|
|
widget.attachment.add(GenericAttachmentModel(id: 0,name: fileImage.path));
|
|
|
|
|
widget.attachment.add(GenericAttachmentModel(id: 0, name: fileImage.path));
|
|
|
|
|
if (widget.onChange != null) {
|
|
|
|
|
widget.onChange!(widget.attachment);
|
|
|
|
|
}
|
|
|
|
|
@ -476,32 +480,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
// ImageSource source = await showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// builder: (dialogContext) => CupertinoAlertDialog(
|
|
|
|
|
// actions: <Widget>[
|
|
|
|
|
// TextButton(
|
|
|
|
|
// child: Text(context.translation.pickFromCamera),
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// Navigator.of(dialogContext).pop(ImageSource.camera);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// TextButton(
|
|
|
|
|
// child: Text(context.translation.pickFromGallery),
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// Navigator.of(dialogContext).pop(ImageSource.gallery);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// TextButton(
|
|
|
|
|
// child: Text(context.translation.pickFromFiles),
|
|
|
|
|
// onPressed: () async {
|
|
|
|
|
// await fromFilePicker();
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
if (source == null) return;
|
|
|
|
|
|
|
|
|
|
final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
|