title: Flutter PageView is crashing if pushReplaceNamed
body: <p>I have a <code>NavBar</code> which I control via a <code>Provider</code> :</p>
  <pre><code>class BottomNavBarProvider extends ChangeNotifier {
    final PageController navigationController = PageController(initialPage: 0);
    int selectedTabIndex = 0;
  
    BottomNavBarProvider() {}
  
    void selectTab(int index) {
      navigationController.jumpToPage(index);
      selectedTabIndex = navigationController.page?.round() ?? 0;
      notifyListeners();
    }
  }
  </code></pre>
  <p><strong>Problem:</strong>
  I think the problem is that I am using a <code>Provider</code> to store my <code>PageContrller</code> so if I push to another page, where the <code>BottomBar</code> is used, it is always attached to the same one from the provider. So I guess I need a way to properly <code>dispose</code> the <code>PageController</code>. But how do I do that?</p>
  <p>I am using it inside my <code>ApplicationContainer</code>:</p>
  <pre><code>class ApplicationContainer extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      initSizeService(context);
  
      return Scaffold(
        body: PageView(
          controller:
              Provider.of&lt;BottomNavBarProvider&gt;(context).navigationController,
          children: &lt;Widget&gt;[
            HomePage(),
            EntryPage(),
            VitalsHistoryPage(
              Provider.of&lt;VitalsHistoryProvider&gt;(context),
            ),
            SettingsPage(),
          ],
          physics: NeverScrollableScrollPhysics(),
        ),
      );
    }
  }
  </code></pre>
  <p>The problem is that I also have a <code>Onboarding-Process</code> in my app and at the last page of it I cam calling <code>Navigator.pushReplacementNamed(context, '/');</code> which is handled by my <code>Router</code>:</p>
  <pre><code>  static Route&lt;dynamic&gt; generateRoute(RouteSettings settings) {
      switch (settings.name) {
        case '/':
          return MaterialPageRoute(
            builder: (context) =&gt; ApplicationContainer(),
          );
          ...
  </code></pre>
  <p>But this crashes my <code>NavBar</code>:</p>
  <blockquote>
  <p>The following assertion was thrown while handling a gesture:
  ScrollController attached to multiple scroll views.
  'package:flutter/src/widgets/scroll_controller.dart':
  Failed assertion: line 109 pos 12: '_positions.length == 1'</p>
  </blockquote>
  <p>Here is the <code>Stack</code>:</p>
  <blockquote>
  <blockquote>
  <p>When the exception was thrown, this was the stack
  #2      ScrollController.position package:flutter/…/widgets/scroll_controller.dart:109
  #3      PageController.jumpToPage package:flutter/…/widgets/page_view.dart:206
  #4      BottomNavBarProvider.selectTab package:onkobutler/providers/bottom_nav_bar_provider.dart:10
  #5      BottomNavBarItem._fireOnTap package:onkobutler/…/bottom_navigation_bar/bottom_nav_bar_item.dart:34
  #6      BottomNavBarItem.build. package:onkobutler/…/bottom_navigation_bar/bottom_nav_bar_item.dart:46</p>
  </blockquote>
  </blockquote>
  <p>And the associated code:</p>
  <pre><code>  List&lt;BottomNavBarItem&gt; _buildBottomNavBarItems(BuildContext context) {
      return [
        BottomNavBarItem(
          index: 0,
          selectedIndex: Provider.of&lt;BottomNavBarProvider&gt;(context, listen: true)
              .selectedTabIndex,
          text: 'Startseite',
          iconBaseUrl: 'images/icons/home_',
          onTap:
              Provider.of&lt;BottomNavBarProvider&gt;(context, listen: false).selectTab,
        ),
        BottomNavBarItem(
          index: 1,
          selectedIndex: Provider.of&lt;BottomNavBarProvider&gt;(context, listen: true)
              .selectedTabIndex,
          text: 'Eintrag',
          iconBaseUrl: 'images/icons/add_black.png',
          hasDynamicIconColor: false,
          onTap: () {
            AppRouter.openEntryProcedure(context);
          },
        ),
        BottomNavBarItem(
          index: 2,
          selectedIndex: Provider.of&lt;BottomNavBarProvider&gt;(context, listen: true)
              .selectedTabIndex,
          text: 'Verlauf',
          iconBaseUrl: 'images/icons/progress_',
          onTap:
              Provider.of&lt;BottomNavBarProvider&gt;(context, listen: false).selectTab,
        ),
        BottomNavBarItem(
          index: 3,
          selectedIndex: Provider.of&lt;BottomNavBarProvider&gt;(context, listen: true)
              .selectedTabIndex,
          text: 'Einstellungen',
          iconBaseUrl: 'images/icons/settings_',
          onTap:
              Provider.of&lt;BottomNavBarProvider&gt;(context, listen: false).selectTab,
        ),
      ];
    }
    }
  </code></pre>
  <p>Why is this happening? What am I missing here?</p>
  <p>Let me know if you need any more info!</p>