maybeGetValue method

T? maybeGetValue(
  1. BuildContext context, [
  2. bool useFallback = false
])

Implementation

T? maybeGetValue(BuildContext context, [bool useFallback = false]) {
  final device = DeviceQuery.of(context);

  switch (device.deviceType) {
    case DeviceType.desktop:
      return _desktop ?? (useFallback ? _fallback : null);

    case DeviceType.phone:
      return _phone ?? (useFallback ? _fallback : null);

    case DeviceType.tablet:
      return _tablet ?? (useFallback ? _fallback : null);

    case DeviceType.tv:
      return _tv ?? (useFallback ? _fallback : null);

    case DeviceType.watch:
      return _watch ?? (useFallback ? _fallback : null);

    case DeviceType.web:
      return _web ?? (useFallback ? _fallback : null);

    default:
      return _fallback;
  }
}