Giter VIP home page Giter VIP logo

Comments (12)

christophsj avatar christophsj commented on June 27, 2024 1

Hi,
I tried to reproduce your issue on my manjaro/kde machine using your provided snippet, however it worked as expected:

Picker Picked image
Screenshot_20240520_153649 Screenshot_20240520_153700

from flutter.

huycozy avatar huycozy commented on June 27, 2024 1

Based on what you found above, I will label this issue for further insights from others.

from flutter.

stuartmorgan avatar stuartmorgan commented on June 27, 2024 1

Therefore, the problem is in Dolphin and KDE file chooser

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 file_selector, instead of using the image_picker wrapper.

from flutter.

huycozy avatar huycozy commented on June 27, 2024

Hi @HarshNarayanJha, I'm not sure if this is a distro-specific issue on your Garuda Linux or not but I don't see this issue on my Ubuntu distro using plugin's example app. Please take a look at my demo screenshots below:

opening picker picked image

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)

from flutter.

HarshNarayanJha avatar HarshNarayanJha commented on June 27, 2024

Thanks for sharing the program. I changed it to use the *.png filtered files, and I was able to see and select those. However GTK only allows one filter AFAIK (using something like image/* is not possible)

To test it out, I just to install a GTK image viewer Image Roll and did ctrl+o in it to open a file. The GTK file picker launched with filter set to Image and all image file types were shown correctly.

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 file_picker. Whatever it may be, we might want reports from other KDE users. I will also try to run the example app.

from flutter.

HarshNarayanJha avatar HarshNarayanJha commented on June 27, 2024

How can I run the example app?

from flutter.

christophsj avatar christophsj commented on June 27, 2024

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),
      ),
    );
  }
}

from flutter.

LimaneGaya avatar LimaneGaya commented on June 27, 2024

Can confirm it works as expected on
[✓] Flutter (Channel master, 3.22.0-36.0.pre.59, on KDE neon 6.0 6.5.0-35-generic, locale fr_FR.UTF-8)
Using the snippet @christophsj provided.

from flutter.

huycozy avatar huycozy commented on June 27, 2024

@HarshNarayanJha Could you confirm with image_picker example or @christophsj's code snippet above?

from flutter.

HarshNarayanJha avatar HarshNarayanJha commented on June 27, 2024

image

Ran the example... same issue. Image files don't show up, but I can manually type and select.

Though if I open the file /packages/image_picker/image_picker_linux/lib/image_picker_linux.dart, and change the mimetype at line 102 from image/* to image/png, all png files are visible (same for jpg)

EDIT:
Interesting discovery! If I use the variable GTK_USE_PORTAL to launch flutter run like this

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 image/* mimetype. Therefore, the problem is in Dolphin and KDE file chooser

from flutter.

HarshNarayanJha avatar HarshNarayanJha commented on June 27, 2024

Sure, I will file this upstream.

in the Windows version, where we hard-code a list of image types

Even Windows explorer doesn't respect image mime types?

from flutter.

stuartmorgan avatar stuartmorgan commented on June 27, 2024

I'm not sure what you are asking exactly, but IFileDialog isn't based on MIME types at all. If you are asking about the Windows Explorer application implementation, you'd need to ask Microsoft.

from flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.