buildScreen method
Implementation
Widget buildScreen(BuildContext context, RouteState routeState) {
return AnimationEffectBuilder(
key: _globalKey,
// Only dispose the old screen AFTER the animation finishes, so the
// user sees a smooth transition rather than a blank frame.
onComplete: () {
_maybeRemoveStaleRoute(_previousRouteForTransition);
},
builder: (context, results) {
final children = _widgetCache.values.toList();
final layerEffects = results.isNotEmpty
? results.map((e) => e.data).first
: null;
return PrioritizedIndexedStack(
// Two indices: current on top, previous underneath. The stack
// renders bottom-up so index 0 is the topmost visible layer.
indices: [
_indexOfRouteState(routeState),
_indexOfRouteState(_previousRouteForTransition),
],
layerEffects: layerEffects,
children: children,
);
},
);
}