Linux challenges with the Flutter game

Tux and Flutter having a tussle
Generated by Gemini

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.

 

 

 

(Visited 4 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *