title: Difference between MaterialPageRoute and PageRouteBuilder
body: <p>To provide custom animations, I can either extend <code>MaterialPageRoute</code> or <code>PageRouteBuilder</code> and they both seem to do the same job. So, what's the difference between the two and which one should I use?</p>
  <p>Here's the code snippet:</p>
  <pre class="lang-dart prettyprint-override"><code>class HomePage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: ElevatedButton(
          onPressed: () =&gt; Navigator.push(context, Foo/BarRoute(Scaffold(appBar: AppBar()))),
          child: Text('Navigate'),
        ),
      );
    }
  }
  
  class FooRoute&lt;T&gt; extends MaterialPageRoute&lt;T&gt; {
    final Widget page;
    FooRoute(this.page) : super(builder: (_) =&gt; page);
  
    @override
    Widget buildTransitions(_, animation, __, ___) {
      return FadeTransition(opacity: animation, child: page);
    }
  }
  
  class BarRoute&lt;T&gt; extends PageRouteBuilder&lt;T&gt; {
    final Widget page;
    BarRoute(this.page) : super(pageBuilder: (_, __, ___) =&gt; page);
  
    @override
    Widget buildTransitions(_, animation, __, ___) {
      return FadeTransition(opacity: animation, child: page);
    }
  }
  </code></pre>
  <p>The only difference I saw was on running the app on an iOS device where <code>MaterialPageRoute</code> tries to insert some iOSed type sliding animation in the background.</p>