I was following the directions under 'Installation' to build the app on Pop OS 22.04. The following resulted. Even in the script, it states it should not be run under sudo or root. However, it attempts to write to /usr/local, which requires root permissions.
Also, I had to put quotes around libstdc++-12-dev (which is listed under Flutter install but not in your script) to get it to install correctly.
