NotificationListener (Flutter Widget of the Week)

Flutter · 164K views · 2020 · 1:17

Open on YouTube

Web developmentSoftware (other)explainer

Why Stack Overflow recommends it

Stack Overflow users link it when answering Flutter questions about detecting scroll events or passing custom notifications up the widget tree, as a quick intro to NotificationListener.

Recommended by 1 people across 1 different months, 2020 to 2023.

What it is

A 1-minute Flutter 'Widget of the Week' episode from the official Flutter channel explaining NotificationListener. It shows how widgets such as ListView dispatch notifications (for example scroll notifications) and how a NotificationListener ancestor can catch and handle them.

What people said

Recommends Hamed Hamedi · 2020-03 · Stack Overflow · on “How to notice when user released his/her finger from scrolling”

Use NotificationListener Widget. Here [this video] is a short clip about it. The code you may want would look like this: @override Widget build(BuildContext context) { return NotificationListener<ScrollNotification>( onNotification: (notification) { if (notification is ScrollStartNotification) { debugPrint('Started'); } if (notification is ScrollUpdateNotification) { debugPrint('Updated'); } if (notification is ScrollEndNotification) { debugPrint('Ended'); } return false; }, child: YourListView(), ); }

Cites Develocode 777 · 2020-09 · Stack Overflow · on “How to change the animation of the parent widget on click of a button present in child widget?”

Wrap your CardFolding with a NotificationListener and when you press on submit dispatch a Notification and control the Animation from the onNotification . [this video]

Cites offworldwelcome · 2023-08 · Stack Overflow · on “How can I create a Flutter widget that detects size changes, similar to how a RenderFlex overflowed error is detected?”

You can use a RenderProxyBox like in your question and the Flutter notification system: [this video] First, create a class to represent your notification. /// Extends from Notification. class SizeReporterNotification extends Notification { const SizeReporterNotification(this.size); /// Notification data. final Size size; } A SingleChildRenderObjectWidget will allow us to wrap some widget in order to create notifications when its size changes. Source: /// A widget that reports its child's size to the notification system. class SizeReporter extends SingleChildRenderObjectWidget { const SizeReporter({super.key, required super.child}); @override RenderObject createRenderObject(BuildContext context) {