updateWidgetIfNeed<T> method
Implementation
Future<bool> updateWidgetIfNeed<T>(RoutePage<T?> page) async {
final RoutePage? oldRoutePage = pages
.whereType<RoutePage<T?>>()
.singleWhereOrNull((element) => element == page);
final Widget? oldWidget = oldRoutePage?.pageConfiguration.child;
if (oldWidget is! Screen) {
return false;
}
final Widget newWidget = page.pageConfiguration.child;
if (oldWidget.runtimeType != newWidget.runtimeType) {
return false;
}
return await oldWidget.events[ScreenEvent.update]?.run(newWidget) ?? false;
}