Search code examples
flutterflutter-dependenciesflutter-testflutter-isar

isar communicates with inspect.isar.dev by default


If you write a flutter app and use the isar storage engine, the running app emits something like this:

flutter: ╔════════════════════════════════════════════════════╗
flutter: ║                ISAR CONNECT STARTED                ║
flutter: ╟────────────────────────────────────────────────────╢
flutter: ║        Open the link to connect to the Isar        ║
flutter: ║       Inspector while this build is running.       ║
flutter: ╟────────────────────────────────────────────────────╢
flutter: ║ https://inspect.isar.dev/3.0.2/#/345/CbIdfsdfsd76  ║
flutter: ╚════════════════════════════════════════════════════╝

Obviously isar inspector requires the running app to call home, so that inspect.isar.dev in a browser window is able to communicate with the running app.

Is this assumption correct?

In case someone needs a purely private development environment, this may conflict with their policy.


Solution

  • isar's open() method allows to disable the inspector, but defaults to true:

      static Future<Isar> open(
        List<CollectionSchema<dynamic>> schemas, {
        String? directory,
        String name = defaultName,
        bool relaxedDurability = true,
        CompactCondition? compactOnLaunch,
        bool inspector = true,
      }) 
    

    If the parameter inspector gets assigned true, the connection to inspect.isar.dev gets prepared by calling _IsarConnect.initialize(schemas):

    /// Tree shake the inspector for profile and release builds.
    assert(() {
      if (!_kIsWeb && inspector) {
        _IsarConnect.initialize(schemas);
      }
      return true;
    }());
    

    Code from isar.dart around line 100.