Tag: Dart

Bizarre Flutter bug – case insesitivity

Bizarre Flutter bug – case insesitivity

Image of an Gemini created image of An Elusive Flutter bug.For the last month or two, I’ve seen this error come up. I’m developing on Windows 11 and using the most update Flutter/Dart in Quail 2 (Android Studio).

 

error: The argument type 'HexGridManager (where HexGridManager is defined in 

d:\development\Onslaught\onclient\lib\flags.dart)' can't be assigned to the parameter type 'HexGridManager 
(where HexGridManager is defined in 
D:\development\Onslaught\onclient\lib\flags.dart)'. (argument_type_not_assignable at [tiled_game_app] lib\tiled_game.dart:298)

The error is it thinks a class that is defined in a file is not the same class as that same class in that same file (yep bizarre!) because the capitalisation of the Drive path differs. D vs d.

I’ve searched the whole project folder for the path using Notepad++ and it turns up surprisingly in 1473 places but when I copied that and looked for a path with a lower case d: it found none.

There is a simple fix. Just close Android Studio and then reopen it. The bug is no longer there.

Linux challenges with the Flutter game

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.

 

 

 

NoSQl or SQL?

NoSQl or SQL?

Da
Image by Gerd Altmann from Pixabay

I’m still continuing C# development but no longer on MonoGame. My needs have now switched to Flutter. If you haven’t come across it, it’s a cross-platform mobile development system from Google and uses their Dart language.  This is a modern language originally created back in 2011 as a potential replacement for JavaScript. That didn’t work out as other browser creators (Microsoft, Apple and Opera) didn’t go for it.

So Dart sort of languished until three years ago when Flutter emerged as an alternative to POA (Plain old Android development in Java/Kotlin). Flutter is the UI technology- interestingly it redraws the screen controls at 60 times per second, a bit like MonoGame. But this is no game.

The UI is programmed in Dart and it has one unique feature: You can make a change and see it live in one second. It’s called Hot Reload and compared to the old Compile, redeploy and run cycle is quite amazing., Also Flutter is cross-platform and has controls for iOS that look like Apple native controls.

Now my big decision is whether to use SQL or NoSQL to store data. The data isn’t exactly ordered like a schema, more like each database record has a variable number of name=value pairs. Which certainly suggests something NoSQLish.