linux_application_id 1.0.0
linux_application_id: ^1.0.0 copied to clipboard
Provides synchronous access to the current Linux application's ID using the GLib/GIO GApplication API. Works with Flutter's default Linux embedder.
Linux Application ID #
This package requires the application to be running under a GLib GApplication.
Flutter's default Linux runner satisfies this requirement.
If an alternative Linux embedder that does not use GApplication is used,
this package may not work as intended.
It uses a conditional import to avoid breaking web builds.
Usage #
import 'package:linux_application_id.dart/linux_application_id.dart';
print(linuxApplicationId());
Motivation #
Why not package_info_plus #
It performs two file I/O operations (asynchronous), parses a JSON file, assumes
that data/flutter_assets/version.json exists, a Flutter-specific file, silently
falls back to empty strings instead of null
if parsing fails, and requires many dependencies (e.g.,
win32).
A lot of overhead, failure points, and dependencies for obtaining the Linux application ID.
Why not read the APPLICATION_ID C macro #
It does not appear to be possible using Dart FFI, and would require native code and Flutter method channels.
Why not Flutter method channels #
They have some overhead compared to FFI and are Flutter specific.
Many platform implementation packages have been rewritten to use FFI, for
example path_provider_foundation,
and some plugins now use JNI on Android (e.g.,
path_provider_android).
Why not code generation or hardcoding #
This works well for application packages, but not for published packages that need access to the running Linux application ID.
It would require explicitly passing the application ID as a String to the
library, which is not ideal for Flutter plugins that use
static void registerWith() to register the platform implementation.