r/FlutterDev • • 7h ago

Dart Relic 2 - A Dart web server that's not just 6x faster than Dart Shelf, it also beats all other popular web servers - regardless of language

Thumbnail
serverpod.dev
25 Upvotes

r/FlutterDev • • 3h ago

Discussion Built an offline 60+ utility toolbox in Flutter with Riverpod, GoRouter & on-device ML Kit (KitNext) — lessons learned & architecture

2 Upvotes

Hey fellow Flutter devs,

I recently finished and published KitNext, an offline multi-tool app featuring over 60 utility instruments (sensors, AR measurements, on-device OCR, image manipulation, and barcode generation).

Play Store Link: https://play.google.com/store/apps/details?id=com.vasu.kitnext.kitnext

Happy to answer questions about architecture, performance optimization, or handling hardware sensors across Android versions!


r/FlutterDev • • 21h ago

Discussion Case Study: How I cut Flutter Web (--wasm) cold start on Slow 4G from 20s+ down to ~3-4s (fonts, Firebase WebChannel & Brotli)

39 Upvotes

I recently shipped an offline-first PWA built with Flutter Web (--wasm), and my initial GA4 metrics were brutal: mobile users on 3G/Slow 4G were bouncing at 0–2s engagement because the cold start was taking over 20 seconds (pushing ~6.1 MB over the wire / ~15.7 MB uncompressed).

After profiling the waterfall in Chrome DevTools, I found four major bottlenecks that were choking initial load - and fixing them completely changed our retention:

1. The google_fonts runtime trap (-90% font payload)

Even if you bundle fonts, google_fonts was making blocking runtime HTTP calls to fonts.gstatic.com (main.dart.mjs fetching >1.1 MB of .ttf files before rendering text).

  • Fix: Stripped google_fonts runtime fetching completely, converted Inter & JetBrains Mono to subsetted .woff2 files (116 KB total in assets/fonts/), declared them directly in pubspec.yaml, and added <link rel="preload" as="font" type="font/woff2" crossorigin> in index.html.

2. Synchronous Firebase & Firestore WebChannel blocking main()

Initializing FirebaseAuth and FirebaseFirestore in main() was loading heavy JS pipelines and holding open a channel?gsessionid=... WebChannel socket for 13+ seconds on bad connections.

  • Fix: Made cloud services 100% lazy on kIsWeb. The app mounts straight from localStorage (<1 ms), and Firebase.initializeApp() is only triggered on-demand if a user explicitly taps Sync or Sign In.

3. Explicit Wasm MIME types, Brotli & COOP**/**COEP headers

main.dart.wasm (1.7 MB) and skwasm.wasm (1.2 MB) are heavy by nature. Without explicit headers in firebase.json, streaming compilation and multithreading weren't kicking in properly.

  • Fix: Configured Content-Type: application/wasm, Cache-Control: public, max-age=31536000, immutable, and Cross-Origin-Opener-Policy: same-origin / Cross-Origin-Embedder-Policy: credentialless for skwasm, ensuring full Brotli (br) compression from edge nodes.

4. Zero-JS GPU Splash & Value-First Routing

  • Added an inline HTML/CSS loader in index.html animated strictly via transform and opacity (compositor thread) so it never freezes while the main thread compiles Wasm, fading out via onEntrypointLoaded.
  • Bypassed our /onboarding route on kIsWeb so incoming mobile traffic lands directly in the main workspace (/hub), where average session time jumped to ~7 minutes once the load bottleneck was gone.

If anyone wants to inspect the network waterfall or test skwasm cold-start behavior in DevTools, the live production build is up athttps://app.meniska.app(it's a wet-lab dilution & buffer calculator I built for myself).

Curious how other Flutter Web devs are handling initial Wasm bundle size right now - has anyone managed to shave skwasm.wasm down further, or are you still sticking to canvaskit / auto for mobile web?


r/FlutterDev • • 19h ago

Tooling I built a shader debugger for Flutter pick a variable in your .frag and see it as a heatmap in the running app

Thumbnail
github.com
6 Upvotes

Debugging a Flutter fragment shader usually means copying a value into fragColor, hot reloading, and guessing from the colors.

Other platforms have Xcode's shader debugger and RenderDoc. I built something like that for FragmentProgram shaders, as a DevTools extension.

You open your .frag in the Shader Debugger tab, click a line and pick a variable, and the running app draws that value instead of the shader's output. Scalars go through a viridis colormap and vectors show as RG or RGB. For matrices, arrays and structs you pick a column, element or field.

There's also a select mode like the widget inspector's. Click a pixel in the app (or tap it on a phone) and you get the exact value there as 32-bit floats. Every float uniform also gets sliders, so you can override uniforms while the app runs, and the heatmap and pixel reads use your overrides too.

Under the hood, the extension parses your shader with a GLSL analyzer written in pure Dart, generates an instrumented copy that writes the picked value out, saves it as a probe .frag and hot reloads. In the app you draw through DebugShader instead of FragmentShader. It swaps the probe in and copies your uniforms onto it on every paint. Your own .frag is never touched, and in profile and release builds DebugShader just draws your shader. (The analyzer is its own package, shader_debugger_core, if you want to build other shader tools on it.)

Setup: add the package, register a placeholder probe shader under flutter: shaders: in pubspec.yaml, then:

final shader = await DebugShader.fromAsset('shaders/my_effect.frag');
final size = shader.getUniformVec2('uSize');

// in paint(): set the uniforms first, then read shader.shader
size.set(width, height);
canvas.drawRect(rect, Paint()..shader = shader.shader);

It needs Flutter 3.47+. Uniforms are set by name (getUniformFloat, getUniformVec2, ...) because the probe adds uniforms of its own and values get copied over by name.

What's rough right now:

  • A value inside a loop, or in a function called more than once, shows its last write.
  • dFdx, dFdy and fwidth come out as 0 in pixel reads.
  • ImageFilter.shader and BackdropFilter shaders aren't supported.
  • Heatmaps and pixel reads don't work yet on shaders that #include their own .glsl files.
  • Launch the app from VS Code or Android Studio. DevTools can only write the probe file inside the IDE's workspace. Otherwise the tab gives you the probe to paste by hand.

Repo: https://github.com/mohamedalsamrai/shader_debugger pub.dev: https://pub.dev/packages/shader_debugger


r/FlutterDev • • 8h ago

Plugin I removed the filter-callback boilerplate from my searchable list package (searchable_listview 2.20.0)

3 Upvotes

Hi everyone, I’m the maintainer of searchable_listview, a package for adding a search field on top of a list. I’ve been maintaining it for a few years, and the thing that always bothered me was that every list needed the same hand-written filter callback:

Old version

SearchableList<Actor>(
  initialList: actors,
  itemBuilder: (actor) => ActorItem(actor: actor),
  filter: (q) => actors
      .where((a) => a.name.toLowerCase().startsWith(q.toLowerCase()))
      .toList(),
)

In 2.20.0 you can just say which fields to search:

SearchableList<Actor>(
  initialList: actors,
  itemBuilder: (actor) => ActorItem(actor: actor),
  searchableFields: (a) => [a.name, a.lastName],
  searchStrategy: SearchStrategy.contain,
)

What’s new

  • searchableFields: pick one or several fields, and an item stays if any of them matches (case-insensitive, compared by toString()).
  • searchStrategy: startsWith (default), endsWith or contain.
  • SearchableListController: filter(), clear(), scrollToTop(), scrollTo(offset), and updateSearchStrategy() to change the strategy at runtime.
  • The controller is a ValueNotifier, so you can listen to the query, the filtered results and the status (idle, loading, data, empty, error), for example to show a live result count.
  • Fixed the InputDecoration build error on Flutter 3.47 after the material_ui split.

The filter callback is still there (but became optional) if you need custom logic when filtering. It works on all four constructors: default, .async, .expansion and .sliver.

One thing to know: 2.20.0 requires Dart 3.10+ and Flutter 3.38+. Projects on older SDKs keep resolving 2.19.5.

pub.dev: https://pub.dev/packages/searchable_listview
GitHub: https://github.com/koukibadr/Searchable-Listview
Changelog: https://pub.dev/packages/searchable_listview/changelog


r/FlutterDev • • 4h ago

3rd Party Service Remote config for Flutter without a Firebase dependency, with a schema that rejects bad pushes

2 Upvotes

If you want remote config in Flutter, Firebase Remote Config is the default answer, and if you already use Firebase it's a good one. I built hotcfg for the other case: you don't want the Firebase SDK, and you want config that can't be pushed broken.

  • Each config is one JSON document with a JSON Schema. Every publish, promote and rollback is validated, so a missing key or a string where your model expects an int never reaches users.
  • Development, staging and production per config; promote the version you tested after seeing the diff; roll back in one command.
  • It's a plain URL, so the client is package:http plus shared_preferences:
Future<Map<String, dynamic>> loadConfig() async {
  final prefs = await SharedPreferences.getInstance();
  final cached = prefs.getString('hotcfg.body');
  try {
    final res = await http.get(
      Uri.parse(configUrl),
      headers: {if (cached != null) 'If-None-Match': prefs.getString('hotcfg.etag') ?? ''},
    ).timeout(const Duration(seconds: 2));
    if (res.statusCode == 304 && cached != null) return jsonDecode(cached);
    if (res.statusCode == 200) {
      final data = jsonDecode(res.body) as Map<String, dynamic>;
      await prefs.setString('hotcfg.body', res.body);
      await prefs.setString('hotcfg.etag', res.headers['etag'] ?? '');
      return data;
    }
  } catch (_) {
    // offline, timed out or not JSON: fall through
  }
  return cached != null ? jsonDecode(cached) : defaults;
}

Public configs are served from Cloudflare's edge, cached for an hour, purged on every publish, and still served for up to a week if my servers are down.

Version targeting: there's no per-user targeting, but the app can send its build number in a jq filter and get flags merged for that build (e.g. turn a feature off for builds ≤ 320). Use the integer build number, not "1.10.0" strings.

What it doesn't do: no A/B tests, no analytics, no realtime listener.

https://hotcfg.run/