plus_plugins
plus_plugins copied to clipboard
[Request]: Use org.freedesktop.portal.NetworkMonitor on Linux
Plugin
connectivity_plus
Use case
I want to distribute my app in a Flatpak sandbox.
The plugin is not allowed to connect to the D-Bus system bus:
flutter: SocketException: Connection failed (OS Error: No such file or directory, errno = 2), address = /var/run/dbus/system_bus_socket, port = 0
Proposal
Flatpak portals are a network daemon agnostic way to fetch network information. It works both inside and outside sandboxes.
https://docs.flatpak.org/en/latest/portal-api-reference.html#gdbus-org.freedesktop.portal.NetworkMonitor
It shjould be used instead of trying to talk directly to NetworkManager.
enum ConnectivityResult { bluetooth, wifi, ethernet, mobile, none, vpn }
vs.
typedef enum {
G_NETWORK_CONNECTIVITY_LOCAL = 1,
G_NETWORK_CONNECTIVITY_LIMITED = 2,
G_NETWORK_CONNECTIVITY_PORTAL = 3,
G_NETWORK_CONNECTIVITY_FULL = 4
} GNetworkConnectivity;
I'm on flatpak too. connectivity_plus doesn't work. What is the work around?
https://pub.dev/documentation/xdg_desktop_portal/latest/xdg_desktop_portal/XdgNetworkMonitorPortal-class.html
Thanks!! I didn't know this existed.
For anyone else that needs this:
import 'package:xdg_desktop_portal/xdg_desktop_portal.dart';
final XdgDesktopPortalClient portal = XdgDesktopPortalClient();
portal.networkMonitor.status.listen((event) {
_hasNetwork = event.available;
});