No more nasty errors during flutter upgrade/channel on Windows (#21085)

Fixes https://github.com/flutter/flutter/issues/14578.
diff --git a/bin/flutter.bat b/bin/flutter.bat
index 43af48b..905b384 100644
--- a/bin/flutter.bat
+++ b/bin/flutter.bat
@@ -103,7 +103,7 @@
     SET update_dart_bin=%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1
     REM Escape apostrophes from the executable path
     SET "update_dart_bin=!update_dart_bin:'=''!"
-    CALL PowerShell.exe -ExecutionPolicy Bypass -Command "Unblock-File -Path '%update_dart_bin%'; & '%update_dart_bin%'"
+    PowerShell.exe -ExecutionPolicy Bypass -Command "Unblock-File -Path '%update_dart_bin%'; & '%update_dart_bin%'"
     IF "%ERRORLEVEL%" NEQ "0" (
       ECHO Error: Unable to update Dart SDK. Retrying...
       timeout /t 5 /nobreak
@@ -153,7 +153,7 @@
 
     POPD
 
-    CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
+    "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
     IF "%ERRORLEVEL%" NEQ "0" (
       ECHO Error: Unable to create dart snapshot for flutter tool.
       SET exit_code=%ERRORLEVEL%
@@ -166,20 +166,15 @@
 
 :after_subroutine
 
-CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
-SET exit_code=%ERRORLEVEL%
-
-REM The VM exits with code 253 if the snapshot version is out-of-date.
-IF "%exit_code%" EQU "253" (
-  CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
-  SET exit_code=%ERRORLEVEL%
-  IF "%exit_code%" EQU "253" (
-    ECHO Error: Unable to create dart snapshot for flutter tool.
-    EXIT /B %exit_code%
-  )
-  CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
-  SET exit_code=%ERRORLEVEL%
-)
+REM Chaining the call to 'dart' and 'exit' with an ampersand ensures that
+REM Windows reads both commands into memory once before executing them. This
+REM avoids nasty errors that may otherwise occure when the dart command (e.g. as
+REM part of 'flutter upgrade') modifies this batch script while it is executing.
+REM
+REM Do not use the CALL command in the next line to execute Dart. CALL causes
+REM Windows to re-read the line from disk after the CALL command has finished
+REM regardless of the ampersand chain.
+"%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %* & exit /B !ERRORLEVEL!
 
 :final_exit
 EXIT /B %exit_code%