of static method

Retrieves the nearest LiquidGlassSettings from the ancestor tree.

This checks for InheritedLiquidGlass first. If not found, it attempts to look up LiquidGlassSettings.of(context) from the renderer package to maintain compatibility with standard LiquidGlassLayer usage.

Implementation

static LiquidGlassSettings? of(BuildContext context) {
  final inherited =
      context.dependOnInheritedWidgetOfExactType<InheritedLiquidGlass>();
  if (inherited != null) {
    return inherited.settings;
  }

  // Fallback to the renderer's provider if available
  try {
    return LiquidGlassSettings.of(context);
  } catch (_) {
    // LiquidGlassSettings.of() might throw or return default if not found,
    // dependent on implementation. We return null if we can't find it.
    return null;
  }
}