title: Flutter: How to jump to last page dynamically created on a PageView
body: <p>I have a pageView displaying a list of pages.</p>
  
  <p>Application provides a + button to add a new page at the end of the collection.</p>
  
  <p>I need the pageView to automatically jump to the last page once this new page has been successfully created.</p>
  
  <p>If I try to redisplay the view providing a provider with initialPosition set to last pageView index, it does not work </p>
  
  <pre><code>PageController(initialPage: 0, keepPage: false);
  </code></pre>
  
  <p>Any implementation idea ?</p>
  
  <ul>
  <li>Using listener (but which listener ?)</li>
  </ul>
  
  <p>Complete code:</p>
  
  <pre><code>  @override
    Widget build(BuildContext context) {
      if (_userId == null) {
        return Scaffold(body: Center(child: Text("Loading experiences")));
      }
      print('Rebuilding entire view.');
      return Scaffold(
        appBar: new AppBar(
            title: StreamBuilder&lt;ExperiencesInfo&gt;(
                stream: _experiencesInfoStream,
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    _selectedExperience = snapshot.data.currentExperience;
                    return Text(snapshot.data.currentExperience.name);
                  } else {
                    return Center();
                  }
                }),
            ),
        body: new Container(
          padding: new EdgeInsets.only(
            top: 16.0,
          ),
          decoration: new BoxDecoration(color: Colors.yellow),
          child: Column(
            children: &lt;Widget&gt;[
              Expanded(
                  child:
                  StreamBuilder&lt;List&lt;Experience&gt;&gt;(
                      stream: _userExperiencesStream,
                      builder: (context, snapshot) {
                        if (snapshot.hasData) {
                          return  _createExperiencesPagesWidget(snapshot.data);
                        } else {
                          return Center();
                        }
                      })
              ),
              _buildPageIndicator(),
              Padding(
                padding: EdgeInsets.only(bottom: 20.0),
              )
            ],
          ),
        ),
        floatingActionButton: new FloatingActionButton(
            child: new Icon(Icons.add),
            onPressed: () {
              _displayAddMenu();
            }),
      );
    }
  
  
  
  _createExperiencesPagesWidget(List&lt;Experience&gt; experiences) {
      print('Creating ExperiencesPagesWidget ${experiences}');
      return PageView.builder(
        physics: new AlwaysScrollableScrollPhysics(),
        controller: _pageController,
        itemCount: experiences.length,
        itemBuilder: (BuildContext context, int index) {
          return ConstrainedBox(
              constraints: const BoxConstraints.expand(),
              child: Column(children: &lt;Widget&gt;[
                _buildMoodIndicator(experiences[index]),
                _buildMoodSelector(),
              ]));
        },
        onPageChanged: (index) {
          if (_actionType == ActionType.none) {
            print('page changed to index: ${index}, updating stream.');
            _experiencesViewModel.experienceIndexSink.add(index);
          } else {
            _actionType = ActionType.none;
          }
  
        },
      );
  </code></pre>
  
  <p>Page controller is defined as a class property</p>
  
  <pre><code>PageController _pageController = PageController(initialPage: 0, keepPage: false);
  </code></pre>