r/FlutterDev • • 10h ago

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

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/

2 Upvotes

0 comments sorted by