Repository: flutter
Issue: [Linux] investigate supporting VS Code CMake integration for native build
Labels: platform-linux,a: desktop,a: build,has reproducible steps,P3,found in release: 3.0,found in release: 3.1,team-linux,triaged-linux

## Steps to Reproduce

1. `flutter create --platforms=linux foo`
2. `cd foo`
3. `flutter build linux --debug`
4. VS Code 2022 > Menu > File > Open Folder > foo/linux 
5. Ctrl + Shift + P > CMake: Configure
6. Ctrl + Shift + P > CMake: Build

**Expected results:**

Build succeeds

**Actual results:** 

Build fails with `RangeError (index): Invalid value: Only valid value is 0: 1`

<details>
  <summary>Build log</summary>

  ```

  [main] Building folder: linux 
  [build] Starting build
  [proc] Executing command: /usr/bin/cmake --build /home/user/Projects/foo/linux/build --config Debug --target all --
  [build] [1/5  20% :: 0.166] Generating ../../flutter/ephemeral/libflutter_linux_gtk.so, ../../flutter/ephemeral/flutter_linux/fl_basic_message_channel.h, ../../flutter/ephemeral/flutter_linux/fl_binary_codec.h, ../../flutter/ephemeral/flutter_linux/fl_binary_messenger.h, ../../flutter/ephemeral/flutter_linux/fl_dart_project.h, ../../flutter/ephemeral/flutter_linux/fl_engine.h, ../../flutter/ephemeral/flutter_linux/fl_json_message_codec.h, ../../flutter/ephemeral/flutter_linux/fl_json_method_codec.h, ../../flutter/ephemeral/flutter_linux/fl_message_codec.h, ../../flutter/ephemeral/flutter_linux/fl_method_call.h, ../../flutter/ephemeral/flutter_linux/fl_method_channel.h, ../../flutter/ephemeral/flutter_linux/fl_method_codec.h, ../../flutter/ephemeral/flutter_linux/fl_method_response.h, ../../flutter/ephemeral/flutter_linux/fl_plugin_registrar.h, ../../flutter/ephemeral/flutter_linux/fl_plugin_registry.h, ../../flutter/ephemeral/flutter_linux/fl_standard_message_codec.h, ../../flutter/ephemeral/flutter_linux/fl_standard_method_codec.h, ../../flutter/ephemeral/flutter_linux/fl_string_codec.h, ../../flutter/ephemeral/flutter_linux/fl_value.h, ../../flutter/ephemeral/flutter_linux/fl_view.h, ../../flutter/ephemeral/flutter_linux/flutter_linux.h, _phony_
  [build] FAILED: ../flutter/ephemeral/libflutter_linux_gtk.so ../flutter/ephemeral/flutter_linux/fl_basic_message_channel.h ../flutter/ephemeral/flutter_linux/fl_binary_codec.h ../flutter/ephemeral/flutter_linux/fl_binary_messenger.h ../flutter/ephemeral/flutter_linux/fl_dart_project.h ../flutter/ephemeral/flutter_linux/fl_engine.h ../flutter/ephemeral/flutter_linux/fl_json_message_codec.h ../flutter/ephemeral/flutter_linux/fl_json_method_codec.h ../flutter/ephemeral/flutter_linux/fl_message_codec.h ../flutter/ephemeral/flutter_linux/fl_method_call.h ../flutter/ephemeral/flutter_linux/fl_method_channel.h ../flutter/ephemeral/flutter_linux/fl_method_codec.h ../flutter/ephemeral/flutter_linux/fl_method_response.h ../flutter/ephemeral/flutter_linux/fl_plugin_registrar.h ../flutter/ephemeral/flutter_linux/fl_plugin_registry.h ../flutter/ephemeral/flutter_linux/fl_standard_message_codec.h ../flutter/ephemeral/flutter_linux/fl_standard_method_codec.h ../flutter/ephemeral/flutter_linux/fl_string_codec.h ../flutter/ephemeral/flutter_linux/fl_value.h ../flutter/ephemeral/flutter_linux/fl_view.h ../flutter/ephemeral/flutter_linux/flutter_linux.h flutter/_phony_ 
  [build] cd /home/user/Projects/foo/linux/build/flutter && /usr/bin/cmake -E env FLUTTER_ROOT=/home/user/snap/flutter/common/flutter PROJECT_DIR=/home/user/Projects/foo DART_OBFUSCATION=false TRACK_WIDGET_CREATION=true TREE_SHAKE_ICONS=false PACKAGE_CONFIG=/home/user/Projects/foo/.dart_tool/package_config.json FLUTTER_TARGET=lib/main.dart /home/user/snap/flutter/common/flutter/packages/flutter_tools/bin/tool_backend.sh Debug
  [build] Unhandled exception:
  [build] RangeError (index): Invalid value: Only valid value is 0: 1
  [build] #0      _Array.[] (dart:core-patch/array.dart:10:36)
  [build] #1      main (file:///home/user/snap/flutter/common/flutter/packages/flutter_tools/bin/tool_backend.dart:12:37)
  [build] #2      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
  [build] #3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
  [build] ninja: build stopped: subcommand failed.
  [build] Build finished with exit code 1

  ```

</details>

<details>
  <summary>Flutter doctor</summary>

  ```
  [✓] Flutter (Channel stable, 3.0.1, on Ubuntu 21.10 5.13.0-44-generic, locale en_US.UTF-8)
      • Flutter version 3.0.1 at /home/user/snap/flutter/common/flutter
      • Upstream repository https://github.com/flutter/flutter.git
      • Framework revision fb57da5f94 (5 days ago), 2022-05-19 15:50:29 -0700
      • Engine revision caaafc5604
      • Dart version 2.17.1
      • DevTools version 2.12.2
  
  [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
      • Android SDK at /home/user/Android/Sdk
      • Platform android-32, build-tools 32.1.0-rc1
      • Java binary at: /usr/local/android-studio/jre/bin/java
      • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
      • All Android licenses accepted.
  
  [✓] Chrome - develop for the web
      • Chrome at google-chrome
  
  [✓] Linux toolchain - develop for Linux desktop
      • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
      • cmake version 3.10.2
      • ninja version 1.8.2
      • pkg-config version 0.29.1
  
  [✓] Android Studio (version 2021.2)
      • Android Studio at /usr/local/android-studio
      • Flutter plugin version 67.1.2
      • Dart plugin version 212.5744
      • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
  
  [✓] VS Code (version 1.67.2)
      • VS Code at /usr/share/code
      • Flutter extension version 3.40.0
  
  [✓] Connected device (2 available)
      • Linux (desktop) • linux  • linux-x64      • Ubuntu 21.10 5.13.0-44-generic
      • Chrome (web)    • chrome • web-javascript • Google Chrome 101.0.4951.64
  
  [✓] HTTP Host Availability
      • All required HTTP hosts are available
  ```

</details>