Image can not be upload through document in iOs #484

This commit is contained in:
Hillel Coren 2023-05-31 08:49:25 +03:00
parent 9506dfe15d
commit 346812c56f
3 changed files with 48 additions and 9 deletions

View File

@ -2,6 +2,7 @@
import 'dart:io';
// Flutter imports:
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -65,8 +66,10 @@ class DocumentGrid extends StatelessWidget {
if (isMobileOS()) ...[
Expanded(
child: AppButton(
iconData: Icons.camera_alt,
label: localization.takePicture,
iconData: isIOS() ? null : Icons.camera_alt,
label: isIOS()
? localization.camera
: localization.takePicture,
onPressed: () async {
final status = await Permission.camera.request();
if (status == PermissionStatus.granted) {
@ -88,18 +91,18 @@ class DocumentGrid extends StatelessWidget {
},
),
),
SizedBox(
width: 14,
),
SizedBox(width: isIOS() ? 8 : 14),
],
Expanded(
child: AppButton(
iconData: Icons.insert_drive_file,
label: localization.uploadFile,
iconData: isIOS() ? null : Icons.insert_drive_file,
label:
isIOS() ? localization.files : localization.uploadFile,
onPressed: () async {
final multipartFile = await pickFile(
fileIndex: 'documents[]',
allowedExtensions: DocumentEntity.ALLOWED_EXTENSIONS);
fileIndex: 'documents[]',
allowedExtensions: DocumentEntity.ALLOWED_EXTENSIONS,
);
if (multipartFile != null) {
onUploadDocument(multipartFile);
@ -107,6 +110,25 @@ class DocumentGrid extends StatelessWidget {
},
),
),
if (isIOS()) ...[
SizedBox(width: isIOS() ? 8 : 14),
Expanded(
child: AppButton(
label: localization.gallery,
onPressed: () async {
final multipartFile = await pickFile(
fileIndex: 'documents[]',
allowedExtensions: DocumentEntity.ALLOWED_EXTENSIONS,
fileType: FileType.image,
);
if (multipartFile != null) {
onUploadDocument(multipartFile);
}
},
),
),
],
],
),
)

View File

@ -18,6 +18,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'files': 'Files',
'camera': 'Camera',
'gallery': 'Gallery',
'email_count_invoices': 'Email :count invoices',
'location': 'Location',
'invoice_task_item_description': 'Invoice Task Item Description',
@ -102526,6 +102529,19 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['email_count_invoices'] ??
_localizedValues['en']['email_count_invoices'];
String get gallery =>
_localizedValues[localeCode]['gallery'] ??
_localizedValues['en']['gallery'];
String get files =>
_localizedValues[localeCode]['files'] ??
_localizedValues['en']['files'];
String get camera =>
_localizedValues[localeCode]['camera'] ??
_localizedValues['en']['camera'];
// STARTER: lang field - do not remove comment
String lookup(String key) {

View File

@ -120,6 +120,7 @@ bool isAndroid() {
}
bool isIOS() {
return true;
if (kIsWeb) {
return false;
}