Tag: Flutter

The perils of updates

The perils of updates

Target dart_build failed: Error: Failed to find any of [ld.lld, ld] in LocalDirectory: '/snap/flutter/149/usr/lib/llvm-10/bin' So I’ve been working on my game and to save time build the web project as a Linux app. It compiles it and runs it quicker than doing it with Chrome.  Until yesterday.

After doing the usual sudo apt update and then upgrade, and snap refresh.I had updated Flutter (and Dart)  and afterwards, upgraded all of the pubspec.yaml and finally ran Flutter Doctor.  It output this

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.38.7, on Ubuntu 24.04.3 LTS 6.14.0-37-generic, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    ✗ cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure to set the ANDROID_HOME environment variable.
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/linux-android-setup for more details.
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 1 category.

I’m not worried about Android so Linux and Chrome were fine; everything is up to date.  Until I tried to run the app (as Linux) and got the message at the top. It says

ERROR: Target dart_build failed: Error: Failed to find any of [ld.lld, ld] in LocalDirectory: 
'/snap/flutter/149/usr/lib/llvm-10/bin'

I can still run it as a Chrome web app so it’s not the end of the world; more a speed bump than a road block but still annoying. I looked up the error but there was nothing really helpful. Installing lld did not fix it.

I asked an AI (Chrome what I could do and it have me three alternatives).

  1. Install a symbolic link to lld but that failed as the area is read only. Even with sudo.
  2. Refresh from a different snap channel but even with a full reboot after doing that it made no difference.
  3. Suggests uninstalling Flutter from snap and install it manually, so that’s what I guess I have to do.

What a faff!

Theming in Flutter – FlexColorScheme

Theming in Flutter – FlexColorScheme

FlexColorScheme playground screenshotOne of Flutter’s big strengths is its supports for theming;  you can define or change colours for every aspect of your UI but it can be a bit complicated. Now an open source project provides a way to simplify things. It’s called FlexColorScheme and is just superb.

The image shows the playground where you can pick a scheme and see how the controls look.

The documentation includes an indepth look at theming. The FlexColorScheme is a Flutter widget and there’s link to the source code on GitHub.  It is highly recommended.

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.