Flutter Blog Jose Alba Mar 2, 2020

Floating Overlay Widgets Over Transformed UI Elements in Flutter

Article Summary

Jose Alba from Google's Material team tackles a tricky Flutter challenge: how do you overlay a widget that follows another widget—even when it's rotated or transformed—without restructuring your entire codebase?

This official Flutter blog post walks through a common UI problem where developers need floating elements (like autocomplete suggestions) to track transformed widgets. Instead of invasive Stack refactoring, Alba demonstrates Flutter's built-in solution using CompositedTransformTarget and CompositedTransformFollower.

Key Takeaways

Critical Insight

Flutter's Overlay system with LayerLink lets you add floating UI elements that track transformed widgets without touching existing code structure.

The article includes interactive DartPad examples showing the technique in action with rotating containers—try breaking it yourself to understand the edge cases.

About This Article

Problem

Adding floating UI features like autosuggestion to text fields in Flutter often means refactoring large parts of your screen. The Stack-based approach is tedious, error-prone, and forces you to redesign entire layouts.

Solution

Jose Alba shows how to use CompositedTransformTarget, CompositedTransformFollower, and LayerLink widgets instead. These widgets attach overlay entries to target widgets and keep position and transformation data intact across different rendering contexts.

Impact

With the Overlay approach, you can add floating widgets to existing routes without restructuring your codebase. Interactive DartPad examples confirm this works, even when widgets rotate or transform.