<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dart | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/dart/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Wed, 18 Feb 2026 13:48:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>Dart | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Tiled is the clear winner</title>
		<link>https://learncgames.com/tiled-is-the-clear-winner/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tiled-is-the-clear-winner</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 18 Feb 2026 13:48:00 +0000</pubDate>
				<category><![CDATA[Dart]]></category>
		<category><![CDATA[Flutter]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[fps]]></category>
		<category><![CDATA[frame rate]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3516</guid>

					<description><![CDATA[<p>I thought maybe the non-tiled hex map program mentioned in my last blog entry would be easier to work with and as fast but just to be on the safe side, I measured the frame rate of both programs. I did this with a nifty bit of Flutter code ceated by an AI that I&#8217;ve [&#8230;]</p>
The post <a href="https://learncgames.com/tiled-is-the-clear-winner/">Tiled is the clear winner</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:837,&quot;href&quot;:&quot;https:\/\/al-e-shevelev.medium.com\/flutter-flame-tiled-a-simple-game-field-prototype-for-a-strategy-game-46518d9c3adc&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20231201064019\/https:\/\/al-e-shevelev.medium.com\/flutter-flame-tiled-a-simple-game-field-prototype-for-a-strategy-game-46518d9c3adc&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-18 13:48:28&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-21 22:45:39&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-25 11:44:03&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-28 22:21:14&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-04 04:16:04&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-07 12:47:53&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-10 16:51:08&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-13 20:06:45&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-16 22:46:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-20 02:27:00&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-23 13:14:03&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 15:24:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-29 21:06:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-01 21:47:11&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 00:09:44&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 08:47:36&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-11 09:31:25&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-14 18:36:42&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 22:45:47&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 08:09:25&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 08:09:25&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img fetchpriority="high" decoding="async" class="alignleft size-full wp-image-3517" src="https://learncgames.com/wp-content/uploads/2026/02/tiled_framerate.png" alt="Tiled frame rate program (link in article)" width="979" height="915" srcset="https://learncgames.com/wp-content/uploads/2026/02/tiled_framerate.png 979w, https://learncgames.com/wp-content/uploads/2026/02/tiled_framerate-300x280.png 300w, https://learncgames.com/wp-content/uploads/2026/02/tiled_framerate-768x718.png 768w" sizes="(max-width: 979px) 100vw, 979px" />I thought maybe the non-tiled hex map program mentioned in my last blog entry would be easier to work with and as fast but just to be on the safe side, I measured the frame rate of both programs.</p>
<p>I did this with a nifty bit of Flutter code ceated by an AI that I&#8217;ve included below. I added it to the program created by <a href="https://al-e-shevelev.medium.com/flutter-flame-tiled-a-simple-game-field-prototype-for-a-strategy-game-46518d9c3adc">Alexander Shevelev</a> who wrote a Medium article about using Flutter + Flame + Tiled. That&#8217;s his program running.</p>
<pre><code class="language-c" data-line="">
import &#039;dart:math&#039; as math;
import &#039;dart:ui&#039;;
import &#039;package:flame/components.dart&#039;;
import &#039;package:flame/events.dart&#039;;
import &#039;package:flame/game.dart&#039;;
import &#039;package:flame/input.dart&#039;;
import &#039;package:flame_tiled/flame_tiled.dart&#039;;
import &#039;package:flame_tiled_example/background.dart&#039;;
import &#039;package:flame_tiled_example/tile_info.dart&#039;;
import &#039;package:flutter/foundation.dart&#039; show kIsWeb;
import &#039;package:flutter/scheduler.dart&#039;;
import &#039;package:flutter/widgets.dart&#039; hide Animation, Image;
import &#039;package:web/web.dart&#039; as web;

class FpsCounter {
  // Singleton instance
  static final FpsCounter _instance = FpsCounter._internal();

  factory FpsCounter() =&gt; _instance;

  FpsCounter._internal();

  bool _running = false;
  int _frameCount = 0;
  double _elapsedMs = 0;

  double fps = 0;

  /// Start measuring FPS
  void start() {
    if (_running) return; // avoid double registration

    _running = true;
    SchedulerBinding.instance.addTimingsCallback(_onTimings);
  }

  /// Stop measuring FPS and remove the global callback
  void stop() {
    if (!_running) return;

    SchedulerBinding.instance.removeTimingsCallback(_onTimings);
    _running = false;
    _frameCount = 0;
    _elapsedMs = 0;
    fps = 0;
  }

  /// Internal callback fired for every frame timing
  void _onTimings(List&lt;FrameTiming&gt; timings) {
    if (!_running) {
      return;
    }

    for (final t in timings) {
      _frameCount++;
      _elapsedMs += t.totalSpan.inMicroseconds / 1000.0;
    }

    // Update about 4 times per second
    if (_elapsedMs &gt;= 250) {
      fps = _frameCount / (_elapsedMs / 1000.0);

      if (kIsWeb) {
        web.document.title = &quot;Hex Map — ${fps.toStringAsFixed(1)} FPS&quot;;
      }

      _frameCount = 0;
      _elapsedMs = 0;
    }
  }
}
void main() { 
    WidgetsFlutterBinding.ensureInitialized(); 
    FpsCounter().start(); // &#x1f448; start measuring FPS 
    runApp( Background( child: GameWidget(game: TiledGame()), 
    ), 
  ); 
}</code></pre>
<p>That puts the FrameRate in the caption. My 40 x 40 hex frame rate was between 6 and 10 FPS,</p>
<p>The Tiled program displayed a 30 x 30 hex grid at just between 250 and 400 FPS! A clear and deserved winner.</p>The post <a href="https://learncgames.com/tiled-is-the-clear-winner/">Tiled is the clear winner</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3516</post-id>	</item>
		<item>
		<title>The joys of Flutter web</title>
		<link>https://learncgames.com/the-joys-of-flutter-web/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-joys-of-flutter-web</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 16 Feb 2026 20:41:47 +0000</pubDate>
				<category><![CDATA[Dart]]></category>
		<category><![CDATA[Flutter]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[hexmap]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3513</guid>

					<description><![CDATA[<p>Originally I was going to use Tiled to draw hexagons in a Flutter web game. But it seemed easier to do it manually without having to worry about working with the .tmx format which is an all singing format based on a XML file structure, and seems more suited to static maps. My game includes [&#8230;]</p>
The post <a href="https://learncgames.com/the-joys-of-flutter-web/">The joys of Flutter web</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignleft size-full wp-image-3514" src="https://learncgames.com/wp-content/uploads/2026/02/hexmap.png" alt="Hexmap running at 10.9 fps" width="934" height="877" srcset="https://learncgames.com/wp-content/uploads/2026/02/hexmap.png 934w, https://learncgames.com/wp-content/uploads/2026/02/hexmap-300x282.png 300w, https://learncgames.com/wp-content/uploads/2026/02/hexmap-768x721.png 768w" sizes="(max-width: 934px) 100vw, 934px" />Originally I was going to use Tiled to draw hexagons in a Flutter web game. But it seemed easier to do it manually without having to worry about working with the .tmx format which is an all singing format based on a XML file structure, and seems more suited to static maps.</p>
<p>My game includes a map generator although that&#8217;s not hooled up yet.</p>
<p>I&#8217;ve been doing experiments and have a Flutter web program displaying a 40 x 40 hexes map, complete with text. It does this at around 6-10 fps.   This is on a 3 1/2 year old PC. I think it should be sufficent frame rate for a web strategy game. It also displays images and there&#8217;s a faint one on the sizth row.</p>
<p>If you look very closely in the middle of the ninth row you might see a hex with the value 2 that&#8217;s been clicked on with a faint circle highighting it.</p>
<p>The hexes aren&#8217;t quite meshing together with a solid border so that needs sorting.</p>The post <a href="https://learncgames.com/the-joys-of-flutter-web/">The joys of Flutter web</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3513</post-id>	</item>
		<item>
		<title>Don&#8217;t get Flutter and Dart mixed up</title>
		<link>https://learncgames.com/dont-get-flutter-and-dart-mixed-up/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dont-get-flutter-and-dart-mixed-up</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 26 Aug 2025 19:23:05 +0000</pubDate>
				<category><![CDATA[Dart]]></category>
		<category><![CDATA[Flutter]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3445</guid>

					<description><![CDATA[<p>I&#8217;m working on a game with a Flutter web client and two Dart terminal programs hence the visual pun. Annoyingly, you can&#8217;t compile a Dart exe for Linux on a Windows PC. You can do that in C# but I prefer to use Dart. I have all the classes in two files (one is called [&#8230;]</p>
The post <a href="https://learncgames.com/dont-get-flutter-and-dart-mixed-up/">Don’t get Flutter and Dart mixed up</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:7,&quot;href&quot;:&quot;https:\/\/pub.dev\/packages\/build_runner&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206102527\/https:\/\/pub.dev\/packages\/build_runner&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:54:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-09 23:16:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 08:02:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 19:00:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 07:40:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 23:30:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 08:43:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-02 21:09:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-06 07:02:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 12:45:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 22:45:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-16 06:35:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-19 14:24:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 20:20:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 02:58:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-29 13:43:28&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 16:50:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 00:55:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-08 08:47:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 09:31:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 00:28:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-18 08:19:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-21 16:07:41&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 16:07:41&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:8,&quot;href&quot;:&quot;https:\/\/api.flutter.dev\/flutter\/foundation\/kIsWeb-constant.html&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251129000631\/https:\/\/api.flutter.dev\/flutter\/foundation\/kIsWeb-constant.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:24:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 20:47:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:29:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 07:02:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 23:41:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 07:05:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 11:01:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 21:09:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 07:02:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 12:45:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 22:44:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-16 05:29:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 14:24:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 20:20:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 02:58:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-29 13:43:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-01 16:50:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 00:55:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 08:47:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 09:31:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 00:28:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 08:19:51&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-21 16:07:41&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 16:07:41&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img decoding="async" class="alignleft size-full wp-image-3446" src="https://learncgames.com/wp-content/uploads/2025/08/flutterandDarts.png" alt="A bird a Flutter and Darts" width="512" height="512" srcset="https://learncgames.com/wp-content/uploads/2025/08/flutterandDarts.png 512w, https://learncgames.com/wp-content/uploads/2025/08/flutterandDarts-300x300.png 300w, https://learncgames.com/wp-content/uploads/2025/08/flutterandDarts-150x150.png 150w, https://learncgames.com/wp-content/uploads/2025/08/flutterandDarts-250x250.png 250w" sizes="(max-width: 512px) 100vw, 512px" /></p>
<p>I&#8217;m working on a game with a Flutter web client and two Dart terminal programs hence the visual pun. Annoyingly, you can&#8217;t compile a Dart exe for Linux on a Windows PC. You can do that in C# but I prefer to use Dart.</p>
<p>I have all the classes in two files (one is called classes.dart) and because I&#8217;m using JSON to persist game data, I use the <a title="Linbk to build_runner on pub.dev" href="https://pub.dev/packages/build_runner" target="_blank" rel="noopener">build_runner</a> package from pub.dev. Just add this before any classes:</p>
<div>
<pre>@JsonSerializable()</pre>
</div>
<div>
<p>Make sure if you have enums that every enum value has</p>
<div>
<pre>@JsonValue('houses')</pre>
</div>
<p>before it and add functions like this for each class you want to persist; in this case a Location class:</p>
<div>
<pre>factory Location.fromJson(Map&lt;String, dynamic&gt; json) =&gt;
    _$LocationFromJson(json);

Map&lt;String, dynamic&gt; toJson() =&gt; _$LocationToJson(this);</pre>
</div>
<p>Then when it&#8217;s all done, do this to generate a file that handles loading and saving the specified classes.</p>
<pre>dart run build_runner build</pre>
</div>
<p>Along the way though I managed to get Flutter into a Dart program. I&#8217;m using SQLite but only in Dart, not in the Flutter app. Unfortunately I used the <a title="Link to Dart API documentation for kIsWeb" href="https://api.flutter.dev/flutter/foundation/kIsWeb-constant.html" target="_blank" rel="noopener"><strong>kIsWeb</strong> constant</a> to exclude some calls (when the classes are used by the Flutter app) in my classes file.  But you can&#8217;t do that in a pure Dart program, it will not compile. Instead I wrote my own function.</p>
<div>
<pre>bool isWeb() {
  return !Platform.isWindows &amp;&amp; !Platform.isLinux;
}</pre>
</div>
<p>Interestingly, the definition of kIsWeb in the API is this below, so it might be worth trying that out.</p>
<p><span class="hljs-keyword">const</span> <span class="hljs-built_in">bool</span> kIsWeb = <span class="hljs-built_in">bool</span>.fromEnvironment(<span class="hljs-string">&#8216;dart.library.js_util&#8217;</span>);</p>The post <a href="https://learncgames.com/dont-get-flutter-and-dart-mixed-up/">Don’t get Flutter and Dart mixed up</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3445</post-id>	</item>
	</channel>
</rss>
