fresnel_platform_interface

The contract shared by fresnel and its platform implementations.

Apps should not depend on this package. Depend on fresnel, which selects the right implementation automatically. This package exists so that adding a platform — fresnel_ios, fresnel_macos, fresnel_android, or one you write yourself — never requires a change to the façade.

What it defines

Type Purpose
Glass The material: regular / clear / identity, plus tinted() and interactive(). Mirrors SwiftUI's Glass struct.
GlassShape Capsule, circle, rounded rectangle, Apple squircle, and container-concentric.
GlassElement One shape inside a container, with geometry already resolved by Flutter's layout pass.
GlassCapabilities What the device can actually do — native glass, Impeller, accessibility flags, system glass intensity.
FresnelPlatform The interface implementations extend.

Implementing a platform

Extend FresnelPlatform and register in registerWith():

class FresnelMyPlatform extends FresnelPlatform {
  static void registerWith() {
    FresnelPlatform.instance = FresnelMyPlatform();
  }

  @override
  Future<GlassCapabilities> capabilities() async => const GlassCapabilities(
        hasNativeGlass: false,
        hasImpeller: true,
      );

  @override
  Widget? buildNativeGlass({...}) => null; // null means "use the shader"

  @override
  Widget? buildNativeContainer({...}) => null;
}

Returning null from the builders is a normal outcome, not an error — it tells the façade to fall through to the shader renderer. A platform that only wants to report capabilities honestly can return null from both.

Answer capabilities natively. Parsing Platform.operatingSystemVersion is a display string, not an API contract; use the platform's own predicate, e.g. ProcessInfo.isOperatingSystemAtLeast on Apple platforms.

Versioning

Breaking changes to this interface are major-version bumps and require every implementation package to be updated in lockstep. Adding a method with a default implementation is not breaking, which is why renderSymbol has one.

License

MIT

Libraries

fresnel_platform_interface
The contract between fresnel and its platform implementations.