-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image picker on Linux doesn't show any files #148635
Comments
Hi @HarshNarayanJha, I'm not sure if this is a distro-specific issue on your
Could you try this on a GTK program on your OS to dig into the issue? (You can adjust my program for this case if it's useful) |
Thanks for sharing the program. I changed it to use the To test it out, I just to install a GTK image viewer If it shows up correctly on ubuntu/gnome gtk, it might be a distro specific issue for KDE/dolphin, or it might even be an issue with the depending package |
How can I run the example app? |
You can clone the https://github.com/flutter/packages/ repository and navigate to flutter/packages/packages/image_picker/image_picker/example and run that project. Or just use a small snippet like this: import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String? _picked;
void _openImagePicker() async {
final ImagePicker picker = ImagePicker();
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
setState(() {
_picked = image?.path;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'Selected:',
),
if (_picked != null)
Image.file(
File(_picked!),
width: 200,
height: 200,
)
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _openImagePicker,
tooltip: 'Pick',
child: const Icon(Icons.browse_gallery),
),
);
}
}
|
Can confirm it works as expected on |
@HarshNarayanJha Could you confirm with image_picker example or @christophsj's code snippet above? |
Ran the example... same issue. Image files don't show up, but I can manually type and select. Though if I open the file EDIT: GTK_USE_PORTAL=0 flutter run It would force the said application to use the gtk file chooser, and in that, all image files are visible with the |
Based on what you found above, I will label this issue for further insights from others. |
I would suggest filing this upstream; if a distro's implementation of the file chooser doesn't follow the spec, there's not much the plugin can do in the general case. If we could detect this case we could fall back to the worse approach used in the Windows version, where we hard-code a list of image types, but we wouldn't want to do that in general, and it's not clear to me that there would be any way to detect this at runtime. As a workaround, clients who need to support this particular environment could do that themselves, using |
Sure, I will file this upstream.
Even Windows explorer doesn't respect image mime types? |
I'm not sure what you are asking exactly, but |
What package does this bug report belong to?
image_picker
What target platforms are you seeing this bug on?
Linux
Have you already upgraded your packages?
Yes
Dependency versions
pubspec.lock
Steps to reproduce
Images
Expected results
The file picker should show image files, and I should be able to pick them
Actual results
No file is visible in the file picker when is opens. This means the filter is wrong.
Code sample
Code sample
I use this code to open the filepicker, which works on Android, but not on Linux
I think the relevant piece of code that opens the file picker in the
image_picker_linux
package is this.Here we can see the mimeType is set to
mimeTypes: <String>['image/*']
, which is seemed to be taken wrong by the linux file picker, and it doesn't show any filesScreenshots or Videos
Screenshots / Video demonstration
This folder does have a lot of images (both jpg and png) and are shown when I open a file picker in chrome through some website that accepts images only, and other apps on linux (like using python to open one with the
image/*
mimetype), but not when launched using flutter and the above codeThis is the list it shows, it would be helpful if it shows the optional
All
type somehowHowever, if I manually try to search in the file name box, suggestions show up based on files in this dir, and if I select that and hit OK, the image shows up in the widget (it is selected!)
Logs
Logs
temp.log
(Log too long)
That's it is shows no errors or no warning upon opening the file picker. Even if I manually select one!
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: