Skip to content

[feature_request] Visibility detector margin support #417

Open
@mj-hd

Description

@mj-hd

Like rootMargin in IntersectionObserver, it would be nice to support setting a detection margin around the VisibilityDetector widget.

For example, this feature enables to prepare required resources (e.g. image fetching, decoding, API request, ...) to show the widget's content before the widget is visible. This may improve the user's experience by fetching the required resources early.

VisibilityDetector(
  key: Key('my-widget-key'),
  margin: const EdgeInsets.symmetric(vertical: -100.0), // this means to expand the detection area 100px vertically
  onVisibilityChanged: (visibilityInfo) {
    if (visibilityInfo.visibleFraction > 0) { 
      prepareForShowingWidget();
    }
  },
  child: someLazyWidget,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions