|
|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:file_picker/file_picker.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
|
import 'package:image_picker/image_picker.dart';
|
|
|
|
|
@ -19,6 +18,7 @@ class MultiFilesPicker extends StatefulWidget {
|
|
|
|
|
final bool error;
|
|
|
|
|
final List<File> files;
|
|
|
|
|
final List<AttachmentModel> attachment;
|
|
|
|
|
|
|
|
|
|
final bool enabled, onlyImages;
|
|
|
|
|
double? buttonHeight;
|
|
|
|
|
Widget? buttonIcon;
|
|
|
|
|
@ -101,6 +101,9 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> {
|
|
|
|
|
if (result != null) {
|
|
|
|
|
for (var path in result.paths) {
|
|
|
|
|
widget.files.add(File(path!));
|
|
|
|
|
if (widget.onChange != null) {
|
|
|
|
|
widget.onChange!(widget.files);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
@ -112,7 +115,7 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImageSource source = (await showModalBottomSheet(
|
|
|
|
|
ImageSource? source = (await showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.vertical(
|
|
|
|
|
@ -143,8 +146,8 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> {
|
|
|
|
|
12.height,
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(21),
|
|
|
|
|
)) as ImageSource;
|
|
|
|
|
|
|
|
|
|
)) as ImageSource?;
|
|
|
|
|
if (source == null) return;
|
|
|
|
|
final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
|
|
|
|
|
|
|
|
|
if (pickedFile != null) {
|
|
|
|
|
@ -193,10 +196,7 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> {
|
|
|
|
|
child: Container(
|
|
|
|
|
constraints: BoxConstraints(minWidth: 111.toScreenWidth, minHeight: 111.toScreenHeight),
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 12.toScreenHeight),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
border: Border.all(width: 1,color:AppColor.white70)
|
|
|
|
|
),
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(width: 1, color: AppColor.white70)),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
@ -209,6 +209,7 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
@ -286,13 +287,10 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AttachmentModel {
|
|
|
|
|
int id = 0;
|
|
|
|
|
File? file;
|
|
|
|
|
|
|
|
|
|
AttachmentModel(this.id, this.file);
|
|
|
|
|
|
|
|
|
|
factory AttachmentModel.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
@ -308,14 +306,13 @@ class AttachmentModel {
|
|
|
|
|
'file': file?.path,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AttachmentPicker extends StatefulWidget {
|
|
|
|
|
final String label;
|
|
|
|
|
final bool error;
|
|
|
|
|
final List<AttachmentModel> attachment;
|
|
|
|
|
|
|
|
|
|
final bool enabled, onlyImages;
|
|
|
|
|
double? buttonHeight;
|
|
|
|
|
Widget? buttonIcon;
|
|
|
|
|
@ -487,10 +484,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
child: Container(
|
|
|
|
|
constraints: BoxConstraints(minWidth: 111.toScreenWidth, minHeight: 111.toScreenHeight),
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 12.toScreenHeight),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
border: Border.all(width: 1,color:AppColor.white70)
|
|
|
|
|
),
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(width: 1, color: AppColor.white70)),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
@ -503,6 +497,7 @@ class _AttachmentPickerState extends State<AttachmentPicker> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
|