Determining dark or light mode in a flatpak sandbox

See here for context https://github.com/rust-windowing/winit/issues/1549.

Through a combination of $XDG_CURRENT_DESKTOP, gsettings, and kreadconfig5, I am able to determine whether an app should use a dark or light theme on gnome/kde when not sandboxed, and assuming dark themes have dark in the name, and light themes do not. Kinda janky, but works in most situations.

Does anyone know if the above env variable/programs are available in a flatpak, and that they give the correct result?