From 8915cf0b8946c8995518b5eb50a5f9a6a43a0df3 Mon Sep 17 00:00:00 2001 From: Hixie Date: Fri, 9 Oct 2015 14:03:54 -0700 Subject: [PATCH] Avoid painting previous routes redundantly ...once the animation is done. --- packages/flutter/lib/src/widgets/navigator.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 97c9e63255..c6345a1a02 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -112,6 +112,16 @@ class NavigatorState extends State { return index >= 0 && index <= _currentPosition; } + void _didCompleteRoute(Route route) { + assert(_history.contains(route)); + if (route.isActuallyOpaque) { + setState(() { + // we need to rebuild because our build function depends on + // whether the route is opaque or not. + }); + } + } + void _didDismissRoute(Route route) { assert(_history.contains(route)); if (_history.lastIndexOf(route) <= _currentPosition) @@ -240,7 +250,9 @@ abstract class Route { } void _handlePerformanceStatusChanged(PerformanceStatus status) { - if (status == PerformanceStatus.dismissed) { + if (status == PerformanceStatus.completed) { + _navigator._didCompleteRoute(this); + } else if (status == PerformanceStatus.dismissed) { _navigator._didDismissRoute(this); _navigator._removeRoute(this); _navigator = null; @@ -266,8 +278,6 @@ abstract class PerformanceRoute extends Route { Duration get transitionDuration; - bool get isActuallyOpaque => (performance == null || _performance.isCompleted) && opaque; - Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance); void didPush(NavigatorState navigator) {