Skip to content

Commit

Permalink
Merge pull request #357 from Tanish2002/fix-linux-file-picker
Browse files Browse the repository at this point in the history
Fix File Picker on linux
  • Loading branch information
animator authored Mar 25, 2024
2 parents baea8ae + f9f185e commit f3a7865
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
onPressed: () async {
var pickedResult = await pickFile();
if (pickedResult != null &&
pickedResult.files.isNotEmpty &&
pickedResult.files.first.path != null) {
pickedResult.path.isNotEmpty) {
formRows[idx] = formRows[idx].copyWith(
value: pickedResult.files.first.path!,
value: pickedResult.path,
);
setState(() {});
_onFieldChange(selectedId!);
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/file_utils.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:io';
import 'dart:typed_data';
import 'package:file_selector/file_selector.dart';
import 'package:path/path.dart' as p;
import 'package:mime_dart/mime_dart.dart';
import 'package:uuid/uuid.dart';
import 'package:path_provider/path_provider.dart';
import 'package:file_picker/file_picker.dart';

const uuid = Uuid();

Expand Down Expand Up @@ -57,7 +57,7 @@ String getTempFileName() {
return getNewUuid();
}

Future<FilePickerResult?> pickFile() async {
FilePickerResult? pickedResult = await FilePicker.platform.pickFiles();
Future<XFile?> pickFile() async {
XFile? pickedResult = await openFile();
return pickedResult;
}
80 changes: 68 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.7.2"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32"
url: "https://pub.dev"
source: hosted
version: "0.3.4+1"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -289,14 +297,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.0"
file_picker:
file_selector:
dependency: "direct main"
description:
name: file_picker
sha256: caa6bc229eab3e32eb2f37b53a5f9d22a6981474afd210c512a7546c1e1a04f6
name: file_selector
sha256: "5019692b593455127794d5718304ff1ae15447dea286cdda9f0db2a796a1b828"
url: "https://pub.dev"
source: hosted
version: "6.2.0"
version: "1.0.3"
file_selector_android:
dependency: transitive
description:
name: file_selector_android
sha256: "1cd66575f063b689e041aec836905ba7be18d76c9f0634d0d75daec825f67095"
url: "https://pub.dev"
source: hosted
version: "0.5.0+7"
file_selector_ios:
dependency: transitive
description:
name: file_selector_ios
sha256: b015154e6d9fddbc4d08916794df170b44531798c8dd709a026df162d07ad81d
url: "https://pub.dev"
source: hosted
version: "0.5.1+8"
file_selector_linux:
dependency: transitive
description:
name: file_selector_linux
sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492"
url: "https://pub.dev"
source: hosted
version: "0.9.2+1"
file_selector_macos:
dependency: transitive
description:
name: file_selector_macos
sha256: b15c3da8bd4908b9918111fa486903f5808e388b8d1c559949f584725a6594d6
url: "https://pub.dev"
source: hosted
version: "0.9.3+3"
file_selector_platform_interface:
dependency: transitive
description:
name: file_selector_platform_interface
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
url: "https://pub.dev"
source: hosted
version: "2.6.2"
file_selector_web:
dependency: transitive
description:
name: file_selector_web
sha256: "619e431b224711a3869e30dbd7d516f5f5a4f04b265013a50912f39e1abc88c8"
url: "https://pub.dev"
source: hosted
version: "0.9.4+1"
file_selector_windows:
dependency: transitive
description:
name: file_selector_windows
sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0
url: "https://pub.dev"
source: hosted
version: "0.9.3+1"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -382,14 +446,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.21"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da
url: "https://pub.dev"
source: hosted
version: "2.0.17"
flutter_riverpod:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ dependencies:
url: https://github.com/foss42/json_data_explorer.git
ref: b7dde2f85dff4f482eed7eda4ef2a71344ef8b3a
scrollable_positioned_list: ^0.3.8
file_picker: ^6.2.0
flutter_svg: ^2.0.10+1
vector_graphics_compiler: ^1.1.9+1
code_builder: ^4.10.0
dart_style: ^2.3.6
json_text_field: ^1.1.0
csv: ^6.0.0
file_selector: ^1.0.3

dependency_overrides:
web: ^0.5.0
Expand Down

0 comments on commit f3a7865

Please sign in to comment.