Layer link

Layer link

Let’s take a look at how to create and display widgets that appear on top of other widgets and follow them when moved. This is an extremely useful experience for various elements like popups, dropdown menus, onboarding tours, and overlays beyond the parent element's rendering boundaries. At the same time, you should not forget that if the parent element is in the list or moves, the screen scrolls or moves in some other way - the overlay will not remain in place at the original coordinates but will follow the parent element.

Saying by examples, after this article, you can create custom drop-down menus like this:

No alt text provided for this image

Pop-up badges, hints, icons, onboarding tours and other widgets:

No alt text provided for this image

Or even more, attach “health bar” to your nimble jumping character:

No alt text provided for this image

Let's imagine you need to attach an overlay to a particular widget.

The problem of drawing overlay entries at specific coordinates doesn't look too hard. But it does. The overall layout of the widget with the overlay is in can be scrolled, transformed, repositioned, or otherwise mutated.

In other words, you should get the overlay following the widget by linking and tieing together two separate layers (parent widget and his overlay follower).

And here, two widgets in Flutter come to our aid. They are helping to connect the parent widget with the overlay: CompositedTransformTarget and CompositedTransformFollower.


To view or add a comment, sign in

More articles by Mike Matiunin

  • Business Logic Component [4 of 4]

    In this final article of the BLoC series, we will look at code examples and practical implementation of several popular…

  • Business Logic Component [3 of 4]

    In the third part of a series of articles about the bloc, we will analyze successful and unsuccessful decisions…

  • Harness the Power of Anonymous Functions in Dart

    Anonymous functions, also known as lambda expressions or closures, are an essential part of modern programming…

  • Handling Asynchronous Dependencies in Flutter & Dart

    In Flutter and Dart applications, it is common to encounter scenarios where a class depends on an asynchronous…

    2 Comments
  • Business Logic Component [1 of 4]

    Introduction You can find the full original article here. We are starting a series of articles about Business Logic…

  • Business Logic Component [2 of 4]

    The second article is from a series of articles about BLoC. You can find the full article here.

  • Anti-patterns of error handling in dart

    This article will show common pitfalls you can make when handling exceptions and how to do it right. The article will…

  • ChangeNotifier selector

    Have you had a situation where you must select and rebuild the interface only to change specific fields of your…

Explore content categories