title: How to prevent NestedScrollView from scrolling if body is small?
body: <p>How do I prevent a <code>NestedScrollView</code> from scrolling the <code>headerSliverBuilder</code> when the <code>body</code> is small?</p>
  
  <p>In the following example, I want to prevent the <code>SliverAppBar</code> from being scrollable if the <code>body</code> does not require scrolling, because it is small, i.e. in this example, the view should not scroll at all, but it does.</p>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
          home: NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return &lt;Widget&gt;[
            SliverAppBar(
              title: Text('Demo'),
              expandedHeight: 300,
            )
          ];
        },
        body: CustomScrollView(
          slivers: &lt;Widget&gt;[
            SliverToBoxAdapter(
              child: Container(color: Colors.red, height: 100),
            ),
            SliverToBoxAdapter(
              child: Container(color: Colors.amber, height: 100),
            ),
          ],
        ),
      ));
    }
  }
  </code></pre>
  
  <p>The problem can be solved by moving the <code>SliverAppBar</code> into the <code>CustomScrollView</code> and not use the <code>NestedScrollView</code> at all. This is not a solution for me though, because <a href="https://github.com/flutter/flutter/issues/12033" rel="noreferrer">https://github.com/flutter/flutter/issues/12033</a> basically requires me to use a <code>NestedScrollView</code>.</p>