Linux challenges with the Flutter game

The architecture of this is all Flutter and Dart running on a Ubuntu Linux box. There are two pure Dart programs- one to create the game setup and one to do the processing. The first is run manually, the second by crontab. Then there’s the Flutter web app.
The Flutter web app has to read and write files from the file system which of course it can’t do directly. I’ve created a backend of sorts using PHP. There’s an API; it works but not without issues. If you’re calling a PHP script from a Flutter app, what is the URL? It depends.
Say the URL is /file?params where I’ve modified .htaccess to pass /file urls onto a PHP script.
If I want to test this on the box in a browser I have to call localhost/file?params but in a Dart program running on the box it just calls /file?params.
The next problem is where are the game files stored. The setup program doesn’t really care. Any location will do so long as it doesn’t need to run elevated. But the web app is limited to /var/www/html – it’s running under Apache on a linux box. In the end I created a folder under /var/www/game and each game is stored under there. PHP can read mostly anywhere, not just in /var/www/html and this provide a little extra security.
However there’s the not-so slight issue of permissions. The setup program runs under my login – call it user. So files are created owned by user user. The web app runs under www-data so to keep things simple, I’ve set permissions to user:www-data so both can access it. It’s a bit of a faff.
Here’s a tip. If you are developing a Flutter web app, develop it on Linux and do development as a Linux app. It’s far quicker building and launching a Linux app than it is the web app.
Well actually I asked Microsoft’s CoPilot AI and it sorted it!
Most of the time I’ve got by configuring VS Code but recently I wasted an hour having managed to completely mess it up. I have a Raspberry Pi version of Asteroids which adds temperature display and game pad support. It’s a useful way to check when I burn a new SD and install VS Code, clang, and all the libSDL2-dev codes that everything is there. If it’s not it won’t compile.
This is more of a tip, but it can be a useful thing to know. If you look at this photo you’ll see it contains a bunch of words. Now you could type them in but that’s a bit tedious.



I needed this in a bit of debug code. I wanted it to work like printf where there’s a format string containing one or more % format specifications and then write this into a buffer and dump it where ever.