<p dir="auto">This isn't a critical problem :-).</p>
<p dir="auto">If you accidentally launch a flutter app with <code class="notranslate">flutter run</code> and lib/main.dart is empty the reported error is not "you have an empty lib/main.dart file" but: "Could not prepare to run the isolate." etc.</p>
<p dir="auto">I can say from personal experience that this is a little confusing.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Launching lib/main.dart on Nexus 5 in debug mode...
Initializing gradle...                                       0.8s
Resolving dependencies...                                    1.1s
Running 'gradlew assembleDebug'...                           9.8s
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...                 12.1s
E/flutter ( 5140): [ERROR:flutter/shell/common/engine.cc(158)] Could not prepare to run the isolate.
E/flutter ( 5140): [ERROR:flutter/shell/common/engine.cc(117)] Engine not prepare and launch isolate.
E/flutter ( 5140): [ERROR:flutter/shell/platform/android/android_shell_holder.cc(166)] Could not launch engine in configuration."><pre class="notranslate"><code class="notranslate">Launching lib/main.dart on Nexus 5 in debug mode...
Initializing gradle...                                       0.8s
Resolving dependencies...                                    1.1s
Running 'gradlew assembleDebug'...                           9.8s
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...                 12.1s
E/flutter ( 5140): [ERROR:flutter/shell/common/engine.cc(158)] Could not prepare to run the isolate.
E/flutter ( 5140): [ERROR:flutter/shell/common/engine.cc(117)] Engine not prepare and launch isolate.
E/flutter ( 5140): [ERROR:flutter/shell/platform/android/android_shell_holder.cc(166)] Could not launch engine in configuration.
</code></pre></div>
<h2 dir="auto">Description</h2>
<p dir="auto">A Scaffold assumes that it is always the height of the device, so when calculating the <code class="notranslate">contentBottom</code> in order to avoid the keyboard, it doesn't include its own offset from the bottom of the screen, resulting in blank space between the keyboard and the <code class="notranslate">body</code>.</p>
<p dir="auto">This behavior occurred for me when attempting to nest scaffolds and create an ios-style BottomNavigationBar layout. The BottomNavigationBar is hosted via Scaffold, and within each tab, I'd like to use a scaffold for the appBar and keyboard avoidance logic.</p>
<h2 dir="auto">Example</h2>
<div dir="auto">
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1535001/49064602-c160e300-f25e-11e8-8136-e9f6485fe958.png"><img width="48%" alt="screen shot 2018-11-27 at 4 06 36 pm" src="https://user-images.githubusercontent.com/1535001/49064602-c160e300-f25e-11e8-8136-e9f6485fe958.png" style="max-width: 100%;"></a>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1535001/49064604-c160e300-f25e-11e8-9693-076b1ca3ca65.png"><img width="48%" alt="screen shot 2018-11-27 at 4 07 55 pm" src="https://user-images.githubusercontent.com/1535001/49064604-c160e300-f25e-11e8-9693-076b1ca3ca65.png" style="max-width: 100%;"></a>
</div>
<h2 dir="auto">Proposed Solution</h2>
<p dir="auto">On line <a href="https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/scaffold.dart#L332">332 in scaffold.dart</a>, we calculate the <code class="notranslate">contentBottom</code> using the <code class="notranslate">viewInsets.bottom</code> of the screen, but without subtracting the widget's own offset from the bottom of the screen. In my screenshots, there's a BottomNavigationBar of height <code class="notranslate">57 + viewInsets.bottom</code> behind the keyboard, so the extra space is equal to <code class="notranslate">57 + viewInsets.bottom</code> points.</p>
<p dir="auto">I'm not quite sure where we'd be able to grab the screen height, but if we could get the screen height, the correct minInsets.bottom calculation would be be <code class="notranslate">viewInsets.bottom - (screenHeight - widgetHeight)</code>.</p>
<h2 dir="auto">Work Around</h2>
<p dir="auto">My workaround at the moment is to make sure that all scaffolds are indeed full screen by putting them in a stack and giving them an empty <code class="notranslate">bottomNavigationBar</code> container.</p>
<p dir="auto">(for context, <code class="notranslate">SwitchStack</code> is just a Stack with Offstage/TickerMode children, and <code class="notranslate">BetterNavigationBar</code> is a simple <code class="notranslate">Row</code> of <code class="notranslate">IconButton</code>s)</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  Widget build(BuildContext context) {
    return Material(
      child: Stack(
        children: &lt;Widget&gt;[
          SwitchStack(
            children: paths
                .map((p) =&gt; FocusScope(node: nodes[p], child: routes[p]))
                .toList(),
            index: currentIndex,
          ),
          Align(
            alignment: Alignment.bottomCenter,
            child: BetterNavigationBar(
              currentIndex: currentIndex,
              onTap: _handleItemSelected,
              items: [
                _buildTabItem(Icons.crop_square, &quot;Spaces&quot;),
                _buildTabItem(Icons.donut_large, &quot;Circles&quot;),
                _buildTabItem(Icons.add, &quot;Action&quot;),
                _buildTabItem(Icons.format_align_justify, &quot;Lines&quot;),
                _buildTabItem(Icons.account_circle, &quot;Dot&quot;),
              ],
            ),
          ),
        ],
      ),
    );
  }"><pre class="notranslate">  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">return</span> <span class="pl-c1">Material</span>(
      child<span class="pl-k">:</span> <span class="pl-c1">Stack</span>(
        children<span class="pl-k">:</span> <span class="pl-k">&lt;</span><span class="pl-c1">Widget</span><span class="pl-k">&gt;</span>[
          <span class="pl-c1">SwitchStack</span>(
            children<span class="pl-k">:</span> paths
                .<span class="pl-en">map</span>((p) <span class="pl-k">=&gt;</span> <span class="pl-c1">FocusScope</span>(node<span class="pl-k">:</span> nodes[p], child<span class="pl-k">:</span> routes[p]))
                .<span class="pl-en">toList</span>(),
            index<span class="pl-k">:</span> currentIndex,
          ),
          <span class="pl-c1">Align</span>(
            alignment<span class="pl-k">:</span> <span class="pl-c1">Alignment</span>.bottomCenter,
            child<span class="pl-k">:</span> <span class="pl-c1">BetterNavigationBar</span>(
              currentIndex<span class="pl-k">:</span> currentIndex,
              onTap<span class="pl-k">:</span> _handleItemSelected,
              items<span class="pl-k">:</span> [
                <span class="pl-en">_buildTabItem</span>(<span class="pl-c1">Icons</span>.crop_square, <span class="pl-s">"Spaces"</span>),
                <span class="pl-en">_buildTabItem</span>(<span class="pl-c1">Icons</span>.donut_large, <span class="pl-s">"Circles"</span>),
                <span class="pl-en">_buildTabItem</span>(<span class="pl-c1">Icons</span>.add, <span class="pl-s">"Action"</span>),
                <span class="pl-en">_buildTabItem</span>(<span class="pl-c1">Icons</span>.format_align_justify, <span class="pl-s">"Lines"</span>),
                <span class="pl-en">_buildTabItem</span>(<span class="pl-c1">Icons</span>.account_circle, <span class="pl-s">"Dot"</span>),
              ],
            ),
          ),
        ],
      ),
    );
  }</pre></div>
<p dir="auto">and each one of those routes renders something like</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: appBar,
      body: body,
      bottomNavigationBar: Container(
        height:
            kBottomNavigationBarHeight + MediaQuery.of(context).padding.bottom,
        color: Colors.transparent,
      ),
    );
  }"><pre class="notranslate">  <span class="pl-k">@override</span>
  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">return</span> <span class="pl-c1">Scaffold</span>(
      appBar<span class="pl-k">:</span> appBar,
      body<span class="pl-k">:</span> body,
      bottomNavigationBar<span class="pl-k">:</span> <span class="pl-c1">Container</span>(
        height<span class="pl-k">:</span>
            kBottomNavigationBarHeight <span class="pl-k">+</span> <span class="pl-c1">MediaQuery</span>.<span class="pl-en">of</span>(context).padding.bottom,
        color<span class="pl-k">:</span> <span class="pl-c1">Colors</span>.transparent,
      ),
    );
  }</pre></div>
<h2 dir="auto"><code class="notranslate">flutter doctor -v</code></h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[✓] Flutter (Channel beta, v0.11.3, on Mac OS X 10.13.6 17G65, locale en-US)
    • Flutter version 0.11.3 at /Users/matt/.flutter-sdk
    • Framework revision 72bf075e8d (2 weeks ago), 2018-11-09 20:36:17 -0800
    • Engine revision 5646e86a6f
    • Dart version 2.1.0 (build 2.1.0-dev.9.3 9c07fb64c4)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/matt/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/matt/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.29.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.20.0

[✓] Connected device (1 available)
    • Rose iPhone • 1af0c70e23fe6c60e7f570442a106b3ea6e33db0 • ios • iOS 12.1

• No issues found!"><pre class="notranslate"><code class="notranslate">[✓] Flutter (Channel beta, v0.11.3, on Mac OS X 10.13.6 17G65, locale en-US)
    • Flutter version 0.11.3 at /Users/matt/.flutter-sdk
    • Framework revision 72bf075e8d (2 weeks ago), 2018-11-09 20:36:17 -0800
    • Engine revision 5646e86a6f
    • Dart version 2.1.0 (build 2.1.0-dev.9.3 9c07fb64c4)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/matt/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/matt/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.29.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.20.0

[✓] Connected device (1 available)
    • Rose iPhone • 1af0c70e23fe6c60e7f570442a106b3ea6e33db0 • ios • iOS 12.1

• No issues found!
</code></pre></div>