WSL に Flutter 環境を作ったときに dart が `Failed to memory map snapshot` で落ちたら

Flutter をセッティングしたときに、以下のような感じでエラーが出た場合

../../runtime/bin/snapshot_utils.cc: 144: error: Failed to memory map snapshot: /home/wsl-user/flutter/bin/cache/dart-sdk/bin/snapshots/kernel-service.dart.snapshot

version=2.14.0 (stable) (Mon Sep 6 13:47:59 2021 +0200) on "linux_x64"
pid=11250, thread=11253, isolate_group=(nil)((nil)), isolate=(nil)((nil))
isolate_instructions=0, vm_instructions=7f89ce0b5320
  pc 0x00007f89ce31f0dc fp 0x00007f89cb76fa50 dart::Profiler::DumpStackTrace(void*)+0x7c
  pc 0x00007f89ce0b54d4 fp 0x00007f89cb76fb30 dart::Assert::Fail(char const*, ...)+0x84
  pc 0x00007f89ce08eb86 fp 0x00007f89cb76fbd0 dart::bin::Snapshot::TryReadAppSnapshot(char const*, bool)+0x256
  pc 0x00007f89ce0927fe fp 0x00007f89cb76fc70 /mnt/i/Android/flutter/bin/cache/dart-sdk/bin/dart+0x1ccf7fe
  pc 0x00007f89ce2750a6 fp 0x00007f89cb76fd00 /mnt/i/Android/flutter/bin/cache/dart-sdk/bin/dart+0x1eb20a6
  pc 0x00007f89ce3a0288 fp 0x00007f89cb76fd80 dart::ThreadPool::WorkerLoop(dart::ThreadPool::Worker*)+0x148
  pc 0x00007f89ce3a06bc fp 0x00007f89cb76fdb0 dart::ThreadPool::Worker::Main(unsigned long)+0x5c
  pc 0x00007f89ce319e88 fp 0x00007f89cb76fe70 /mnt/i/Android/flutter/bin/cache/dart-sdk/bin/dart+0x1f56e88
-- End of DumpStackTrace
/mnt/i/Android/flutter/bin/internal/shared.sh: line 162: 11250 Aborted                 (core dumped) "$DART" --verbosity=error --disable-dart-dev $FLUTTER_TOOL_ARGS --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" --no-enable-mirrors "$SCRIPT_PATH"

Flutter の Issue では再現困難のためクローズされていますが、いろいろ試したところ、WSL1の場合に発生するようでした。

使用中の WSL 環境を確認しましょう

# 一度 WSL から抜けて、Windows 側の シェルで確認
> wsl -l -v
  NAME                   STATE           VERSION
  flutter-env            Running         1

VERSION が 1 となっている場合は、以下コマンドでバージョンを変更しましょう

> wsl --set-version flutter-env 2