duo_animation 0.1.0
duo_animation: ^0.1.0 copied to clipboard
iPhone Duo style tilt-driven frosted-glass fold effect for any Flutter widget subtree. Device motion drives a fragment shader on Impeller.
0.1.0 #
First release.
DuoFoldwraps any widget subtree and renders it behind a hinged pane of frosted glass. Tilt magnitude and lift direction are passed in, so the effect can be driven by anything: a sensor, an animation, a slider. The child is rasterized into a layer and run through a fragment shader, which means it has to be Flutter-drawn. Platform views and texture widgets do not participate in a layer filter. BelowDuoFold.tiltEpsilonthe widget renders the child directly and skips the layer and the shader entirely.DuoFoldMotionis the sensor-driven form: hand it aDuoFoldControllerand it rebuilds only the filter wrapper on each sample, so the sensor stream does not rebuild the subtree being folded.DuoFoldControllerowns the sensor subscription and the tilt filter and publishes the result as aChangeNotifier. It runs in one of two modes against the same output, either from the sensor or frommanualTiltDegreesfor emulators and tuning sessions, and falls back to manual on a device with no rotation sensor.DuoFoldParameterscarries the physical tuning: viewing distance and the perspective it implies, how fast frost thickens with distance from the hinge, how much light the glass loses, and what colour it scatters toward. The base frost is specified in millimetres of physical screen, so it holds its size across densities.DuoFoldConstraintslimits which hinges the fold may resolve to:free,horizontal,vertical, or an explicit set. Constraints apply before the tilt is published, so the readout and the effect always agree and swapping them at runtime needs no recalibration.FakeMotionSourcefeeds the controller scripted samples, so an app's own tests can drive the effect without a device.- Android and iOS, both through Pigeon. Attitude is read in a reference frame that excludes the magnetometer, so a passing magnet does not shift the pose the effect is measured against. Calibration, latency prediction, smoothing and drift washout all live in Dart.
- Requires the Impeller renderer. Any other backend throws
DuoFoldUnsupportedErrorrather than quietly rendering the child unfiltered.
