natsuk4ze / gal

How to Save Image or Video to Photo Gallery in Flutter
https://pub.dev/packages/gal
BSD 3-Clause "New" or "Revised" License
85 stars 13 forks source link

Add support for Linux desktop platform #164

Closed EchoEllet closed 7 months ago

EchoEllet commented 8 months ago

This is just the very first steps of adding support for Linux, it's not ready yet, but I will complete this soon, let me know if you are interested in adding support for Linux

Feature request

It also needs more testing on different Linux distros and I will soon.

EchoEllet commented 8 months ago

Hi @natsuk4ze

You might want to consider reviewing the code before I go further

natsuk4ze commented 8 months ago

Can we move linux folder which linux related to top level? It should not to put code under lib/ that is only used on Linux. Federated plugins might be possible.

EchoEllet commented 8 months ago

Can we move linux folder which linux related to top level? It should not to put code under lib/ that is only used on Linux. Federated plugins might be possible.

The Linux folder contains dart code. How will we use the dart code that is outside of the lib?? The name of the Linux folder doesn't matter much it could be anything

The only way is to move the implementation to native code using the method channel

because it doesn't have any call to an API or library that is specific to Linux

check the imports:

import 'dart:io' show Directory, File, Platform, ProcessException;

import 'package:flutter/foundation.dart' show Uint8List, immutable, kIsWeb;
import 'package:flutter/services.dart' show PlatformException;
import 'package:gal/src/gal_exception.dart';
import 'package:gal/src/utils/command_line.dart';
import 'package:gal/src/utils/extensions/uri.dart';

and the file is just 235 lines of code which is not much

the specific logic to Linux is the commands we are running using the process in Dart, which is just a string as input and it will give us output

Linux works differently from macOS, windows, and the the others, even if we move the logic to the native code we still use the command line there and not use much specific thing to Linux, in that case then we didn't do much

I prefer doing it the way we are doing it right now, but if insist, let me know, so I move everything to the method channel

image

EchoEllet commented 7 months ago

I will return to Linux support later but it looks like I will need more time

natsuk4ze commented 7 months ago

Understood. I appreciate your work @freshtechtips . There is no need to rush. Originally, adding a platform should be a prudent thing to do.

I will always accept high quality PR that meets the requirements. Thank you again 💚

EchoEllet commented 7 months ago

Understood. I appreciate your work @freshtechtips . There is no need to rush. Originally, adding a platform should be a prudent thing to do.

I will always accept high quality PR that meets the requirements. Thank you again 💚

Hi again, thank you for your understanding

The main reason why I closed it is because this whole PR added support for Linux in dart code, and it requires checking if the platform is Linux every time for all platforms

Next time it will be in C++ native Linux code

natsuk4ze commented 7 months ago

Understood. I appreciate your work @freshtechtips . There is no need to rush. Originally, adding a platform should be a prudent thing to do.

I will always accept high quality PR that meets the requirements. Thank you again 💚

Hi again, thank you for your understanding

The main reason why I closed it is because this whole PR added support for Linux in dart code, and it requires checking if the platform is Linux every time for all platforms

Next time it will be in C++ native Linux code

Yes, my ideal would be to be able to add a new platform without any changes under the lib folder.