title: Flutter: ScrollController initialScrollOffset not working
body: <p>I'm trying to initialize a SingleChildScrollView to start at a certain position with a custom ScrollController. I thought I could use initialScrollOffset and set an initial value in the init method. But somehow when the SingleChildScrollView renders, it only jumps to initialOffset at first build, then when I navigate to another instance of this Widget it doesn't jump to the initialOffset position.</p>
  
  <p>I don't know why, and if I'm lucky maybe one of you have the answer.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>class Artiklar extends StatefulWidget {
    final String path;
    final double arguments;
  
    Artiklar({
      this.path,
      this.arguments,
    });
  
    @override
    _ArtiklarState createState() =&gt; _ArtiklarState(arguments: arguments);
  }
  
  class _ArtiklarState extends State&lt;Artiklar&gt; {
    final double arguments;
  
    _ArtiklarState({this.arguments});
  
    ScrollController _scrollController;
    double scrollPosition;
  
    @override
    void initState() {
      super.initState();
      double initialOffset = arguments != null ? arguments : 22.2;
      _scrollController = ScrollController(initialScrollOffset: initialOffset);
    }
  
    @override
    void dispose() {
      _scrollController.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      final bool isAdmin = Provider.of&lt;bool&gt;(context) ?? false;
  
      var pathElements = widget.path.split('/');
      String tag;
      if (pathElements.length == 2) {
        tag = null;
      } else if (pathElements.length == 3) {
        tag = pathElements[2];
      } else {
        tag = null;
      }
  
      return StreamBuilder&lt;List&lt;ArtikelData&gt;&gt;(
        stream: DatabaseService(tag: tag).artiklarByDate,
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.active) {
            return GlobalScaffold(
              body: SingleChildScrollView(
                child: Container(
                  child: Center(
                    child: Container(
                      padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: &lt;Widget&gt;[
                          GradientHeading(text: "Artiklar", large: true),
                          isAdmin
                              ? NormalButton(
                                  text: "Skapa ny artikel",
                                  onPressed: () {
                                    Navigator.pushNamed(
                                        context, createNewArtikelRoute);
                                  },
                                )
                              : Container(),
                          SizedBox(height: 10),
                          SingleChildScrollView(
                            controller: _scrollController,
                            scrollDirection: Axis.horizontal,
                            child: TagList(path: tag),
                          ),
                          SizedBox(height: 10),
                          LatestArtiklar(
                            snapshot: snapshot,
                            totalPosts: snapshot.data.length,
                            numberOfPosts: 10,
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ),
            );
          } else if (!snapshot.hasData) {
            return GlobalScaffold(
              body: SingleChildScrollView(
                child: Container(
                  child: Center(
                    child: Container(
                      padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: &lt;Widget&gt;[
                          GradientHeading(text: "Artiklar", large: true),
                          SizedBox(height: 10),
                          SingleChildScrollView(
                            scrollDirection: Axis.horizontal,
                            child: TagList(path: tag),
                          ),
                          SizedBox(height: 10),
                          LatestArtiklar(hasNoPosts: true)
                        ],
                      ),
                    ),
                  ),
                ),
              ),
            );
          } else {
            return GlobalScaffold(
              body: Center(child: CircularProgressIndicator()),
            );
          }
        },
      );
    }
  }
  </code></pre>