readAppDevicePixelRatio function

Future<double?> readAppDevicePixelRatio()

Asks the running app for its FlutterView's device pixel ratio via ext.fdb.lifecycle. Null when there is no app session, fdb_helper is older than the field, or the call takes over 2 s.

Implementation

Future<double?> readAppDevicePixelRatio() async {
  try {
    return await _readAppDevicePixelRatio().timeout(const Duration(seconds: 2));
  } catch (_) {
    // Advisory: the caller falls back to `wm density`.
    return null;
  }
}