跳至主要內容

SizeChangedLayoutNotifier SizeChangedLayoutNotification

xiaoye小于 1 分钟

SizeChangedLayoutNotifier

当子组件尺寸发生变化时,此组件发出通知(Notification),通知类型为SizeChangedLayoutNotification。

NotificationListener(
  onNotification: (notification) {
    print('child:$notification');
    return false;
  },
  child: SizeChangedLayoutNotifier(
    child: Container(width: size, height: size, color: Colors.red),
  ),
),

当改变size大小时,onNotification接收到通知,打印如下:

flutter: child:SizeChangedLayoutNotification()

NotificationListeneropen in new window 是接收通知到组件。

SizeChangedLayoutNotification

SizeChangedLayoutNotification继承自LayoutChangedNotification,其本质就是一个Notification