|
|
|
@ -45,7 +45,19 @@ class ImageOptions {
|
|
|
|
onFilesTap: () async {
|
|
|
|
onFilesTap: () async {
|
|
|
|
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
|
|
|
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
|
|
|
type: FileType.custom,
|
|
|
|
type: FileType.custom,
|
|
|
|
allowedExtensions: ['jpg', 'jpeg ', 'pdf', 'txt', 'docx', 'doc', 'pptx', 'xlsx', 'png', 'rar', 'zip',],
|
|
|
|
allowedExtensions: [
|
|
|
|
|
|
|
|
'jpg',
|
|
|
|
|
|
|
|
'jpeg ',
|
|
|
|
|
|
|
|
'pdf',
|
|
|
|
|
|
|
|
'txt',
|
|
|
|
|
|
|
|
'docx',
|
|
|
|
|
|
|
|
'doc',
|
|
|
|
|
|
|
|
'pptx',
|
|
|
|
|
|
|
|
'xlsx',
|
|
|
|
|
|
|
|
'png',
|
|
|
|
|
|
|
|
'rar',
|
|
|
|
|
|
|
|
'zip',
|
|
|
|
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
List<File> files = result!.paths.map((path) => File(path!)).toList();
|
|
|
|
List<File> files = result!.paths.map((path) => File(path!)).toList();
|
|
|
|
image(result.files.first.path.toString(), files.first);
|
|
|
|
image(result.files.first.path.toString(), files.first);
|
|
|
|
@ -54,67 +66,68 @@ class ImageOptions {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void showImageOptions(BuildContext context, Function(String, File) image) {
|
|
|
|
// static void showImageOptions(BuildContext context, Function(String, File) image) {
|
|
|
|
showModalBottomSheet(
|
|
|
|
// showModalBottomSheet(
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
context: context,
|
|
|
|
// context: context,
|
|
|
|
builder: (BuildContext bc) {
|
|
|
|
// builder: (BuildContext bc) {
|
|
|
|
return _BottomSheet(
|
|
|
|
// return _BottomSheet(
|
|
|
|
children: <Widget>[
|
|
|
|
// children: <Widget>[
|
|
|
|
_BottomSheetItem(
|
|
|
|
// _BottomSheetItem(
|
|
|
|
title: "Select File Source",
|
|
|
|
// title: "Select File Source",
|
|
|
|
onTap: () {},
|
|
|
|
// onTap: () {},
|
|
|
|
icon: Icons.file_present,
|
|
|
|
// icon: Icons.file_present,
|
|
|
|
color: MyColors.black,
|
|
|
|
// color: MyColors.black,
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
_BottomSheetItem(
|
|
|
|
// _BottomSheetItem(
|
|
|
|
title: "Gallery",
|
|
|
|
// title: "Gallery",
|
|
|
|
icon: Icons.image,
|
|
|
|
// icon: Icons.image,
|
|
|
|
onTap: () async {
|
|
|
|
// onTap: () async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
// if (Platform.isAndroid) {
|
|
|
|
galleryImageAndroid(image);
|
|
|
|
// galleryImageAndroid(image);
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 10))?.path ?? "");
|
|
|
|
// File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 10))?.path ?? "");
|
|
|
|
String fileName = _image.path;
|
|
|
|
// String fileName = _image.path;
|
|
|
|
var bytes = File(fileName).readAsBytesSync();
|
|
|
|
// var bytes = File(fileName).readAsBytesSync();
|
|
|
|
String base64Encode = base64.encode(bytes);
|
|
|
|
// String base64Encode = base64.encode(bytes);
|
|
|
|
if (base64Encode != null) {
|
|
|
|
// if (base64Encode != null) {
|
|
|
|
image(base64Encode, _image);
|
|
|
|
// image(base64Encode, _image);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
// },
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
_BottomSheetItem(
|
|
|
|
// _BottomSheetItem(
|
|
|
|
title: "Camera",
|
|
|
|
// title: "Camera",
|
|
|
|
icon: Icons.camera_alt,
|
|
|
|
// icon: Icons.camera_alt,
|
|
|
|
onTap: () async {
|
|
|
|
// onTap: () async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
// if (Platform.isAndroid) {
|
|
|
|
cameraImageAndroid(image);
|
|
|
|
// cameraImageAndroid(image);
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 10))?.path ?? "");
|
|
|
|
// File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 10))?.path ?? "");
|
|
|
|
String fileName = _image.path;
|
|
|
|
// String fileName = _image.path;
|
|
|
|
var bytes = File(fileName).readAsBytesSync();
|
|
|
|
// var bytes = File(fileName).readAsBytesSync();
|
|
|
|
String base64Encode = base64.encode(bytes);
|
|
|
|
// String base64Encode = base64.encode(bytes);
|
|
|
|
if (base64Encode != null) {
|
|
|
|
// if (base64Encode != null) {
|
|
|
|
image(base64Encode, _image);
|
|
|
|
// image(base64Encode, _image);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
// },
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
_BottomSheetItem(
|
|
|
|
// _BottomSheetItem(
|
|
|
|
title: "Cancel",
|
|
|
|
// title: "Cancel",
|
|
|
|
onTap: () {},
|
|
|
|
// onTap: () {},
|
|
|
|
icon: Icons.cancel,
|
|
|
|
// icon: Icons.cancel,
|
|
|
|
color: MyColors.redColor,
|
|
|
|
// color: MyColors.redColor,
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
// ],
|
|
|
|
);
|
|
|
|
// );
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void galleryImageAndroid(Function(String, File) image) async {
|
|
|
|
void galleryImageAndroid(Function(String, File) image) async {
|
|
|
|
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? "");
|
|
|
|
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? "");
|
|
|
|
|
|
|
|
|
|
|
|
String fileName = _image.path;
|
|
|
|
String fileName = _image.path;
|
|
|
|
var bytes = File(fileName).readAsBytesSync();
|
|
|
|
var bytes = File(fileName).readAsBytesSync();
|
|
|
|
String base64Encode = base64.encode(bytes);
|
|
|
|
String base64Encode = base64.encode(bytes);
|
|
|
|
|