title: How to make ListView preserve its scroll when transitioning to another route?
body: <p>I want to accomplish slide to right transition in my flutter application.
  The problem is that route transition kinda creates new instance of page that I want to transit from, and so <code>ListView</code> scroll resets.</p>
  <p><a href="https://youtu.be/-PdLhyvNoU8" rel="nofollow noreferrer">See a video</a></p>
  <p>That's how I create a new route</p>
  <pre class="lang-dart prettyprint-override"><code>/// @oldRoute needed cause this route transition utilizes `SlideStackRightRoute`
  Route createSettingsRoute(Widget oldRoute) {
    return SlideStackRightRoute(exitPage: oldRoute, enterPage: SettingsRoute());
  }
  </code></pre>
  <p>And finally slide transition class itself</p>
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  
  /// Creates cupertino-like route transition, where new route pushes old from right to left
  class SlideStackRightRoute extends PageRouteBuilder {
    final Widget enterPage;
    final Widget exitPage;
    static var exBegin = Offset(0.0, 0.0);
    static var exEnd = Offset(-0.5, 0.0);
    static var entBegin = Offset(1.0, 0.0);
    static var entEnd = Offset.zero;
    static var curveIn = Curves.easeOutSine;
    static var curveOut = Curves.easeInSine;
  
    SlideStackRightRoute({@required this.exitPage, @required this.enterPage})
        : super(
            transitionDuration: Duration(milliseconds: 400),
            pageBuilder: (
              BuildContext context,
              Animation&lt;double&gt; animation,
              Animation&lt;double&gt; secondaryAnimation,
            ) =&gt;
                enterPage,
            transitionsBuilder: (
              BuildContext context,
              Animation&lt;double&gt; animation,
              Animation&lt;double&gt; secondaryAnimation,
              Widget child,
            ) =&gt;
                Stack(
              children: &lt;Widget&gt;[
                SlideTransition(
                  position: Tween(begin: exBegin, end: exEnd)
                      .chain(CurveTween(curve: curveIn))
                      .chain(CurveTween(curve: curveOut))
                      .animate(animation),
                  child: Container(
                      foregroundDecoration: BoxDecoration(
                        color: Colors.black.withOpacity(animation.value / 2),
                      ),
                      child: exitPage),
                ),
                SlideTransition(
                  position: Tween(begin: entBegin, end: entEnd)
                      .chain(CurveTween(curve: curveIn))
                      .chain(CurveTween(curve: curveOut))
                      .animate(animation),
                  child: enterPage,
                )
              ],
            ),
          );
  }
  
  </code></pre>