Skip to main content

squiddy_flutter 0.8.0 copy "squiddy_flutter: ^0.8.0" to clipboard
squiddy_flutter: ^0.8.0 copied to clipboard

Remote configuration, offline cache and app gate from a Squiddy server for Flutter apps on Android, iOS and the web, through the Squiddy SDK itself.

squiddy_flutter #

The Flutter plugin of the Squiddy SDK, for Android, iOS and the web: the resolved configuration of the app from a Squiddy server, its gate (update required, maintenance) and its localized strings, with the offline cache, the conditional calls, the backoff and, on Android and iOS, the push updates of the SDK itself. The guide, from the installation to the push update, is https://docs.squiddy.cloud/sdk/flutter.html, and a whole app is the SDK's Flutter sample.

flutter pub add squiddy_flutter

The plugin has the version of the SDK it wraps (0.5.0 is the first), and requires that same version of the SDK's packages: on Android and iOS the build takes them, on the web the page loads the npm package (see the web).

final squiddy = await Squiddy.initialize(const SquiddyOptions(
  host: 'https://squiddy.example.com',
  apiKey: 'sqd_…',
  appId: 'my-app',
  appVersion: '2026.11.28', // YYYY.MM.DD
  appMode: 'release',
));

StreamBuilder<AppGate>(
  stream: squiddy.gate,
  initialData: squiddy.gate.value,
  builder: (context, snapshot) => switch (snapshot.requireData.kind) {
    AppGateKind.none => const HomeScreen(),
    AppGateKind.updateRequired => UpdateScreen(snapshot.requireData),
    AppGateKind.maintenance => MaintenanceScreen(snapshot.requireData),
  },
);

final title = squiddy.string('welcome_title', fallback: 'Welcome');
await squiddy.handlePush(Map<String, String>.from(message.data)); // a firebase_messaging message

One SDK #

The plugin is a bridge, and copies none of the SDK's logic: on Android it runs the SDK's library (cloud.squiddy:squiddy-android on Maven Central), on iOS its Swift package (squiddy-cloud/squiddy-swift), on the web its npm package (@squiddy-cloud/sdk), all of the plugin's own version. Every call crosses a platform channel to the SDK's public API, or on the web calls the npm package through dart:js_interop, and every value comes from the SDK's own listeners. The strings and the typed readings of the settings are resolved by the SDK on the platform and handed over resolved (LocalizedStrings.toMap() of the core, strings.keys() of the npm package), so that string(key) reads them at once in Dart.

The Dart API follows the common contract of the SDK's wrappers (conformance/contract.json in its repository): the same options, members, types and closed sets, with the names spelled the Dart way (enums in lowerCamelCase, Duration for the durations). Every call that crosses to the platform returns a Future; the values (config, gate, strings) are SquiddyObservables, which have their value now and are Streams that start with it.

  • Android: API 24 or later; the app compiles against API 37, as the SDK's library requires.
  • iOS: iOS 15 or later, through Swift Package Manager, which Flutter uses by default. CocoaPods is not supported.
  • Web: a browser with ES modules and import maps (any current Chrome, Edge, Firefox or Safari), compiled to JavaScript or to WebAssembly.

The web #

On the web the SDK runs as its npm package, which the page loads: the plugin imports it by its name, @squiddy-cloud/sdk, at the first Squiddy.initialize, and the app's web/index.html maps that name to the package's module, squiddy.mjs, in an import map before Flutter starts, as the SDK's web sample does:

<script type="importmap">
  { "imports": { "@squiddy-cloud/sdk": "./squiddy/squiddy.mjs" } }
</script>

Here the files of the package, at the plugin's version (npm install @squiddy-cloud/sdk@<version>, then its folder node_modules/@squiddy-cloud/sdk copied to web/squiddy), are served with the app; the map may name any URL of the same files, a bundler's output included. Without the map, Squiddy.initialize throws a StateError that says so.

In a page the SDK keeps its configuration in localStorage, takes the page's host name as the bundle id and the browser's language, and checks the configuration at once, whenever the page becomes visible again and, while it is visible, every refresh interval of the configuration. Squiddy's data plane answers the browser's CORS checks for every origin.

No push on the web, as in the npm package, which has none: a page cannot subscribe to a topic of Firebase Cloud Messaging (subscribeToTopic of firebase_messaging is not supported on the web either), and the checks above keep the page current. So handlePush returns false and does nothing, and the same firebase_messaging handler serves every platform; pushTopic throws an UnsupportedError, so the subscription stays behind the check the app already needs for Firebase (if (!kIsWeb)); and the option pushRefreshJitter is not used.

Developing #

From this folder, with Flutter 3.50.1:

flutter pub get
flutter analyze && dart format --output=none --set-exit-if-changed .
flutter test --coverage                     # the Dart side, against a fake channel and a fake npm package
flutter test --platform chrome test/web     # the web side's interop, in Chrome, against a fake of the npm package
dart run tool/api_dump.dart                 # the public API against api/squiddy_flutter.api (--update rewrites it)
tool/run-integration-tests.sh android       # every case of the conformance kit on the running emulator
tool/run-integration-tests.sh ios           # the same on an iOS simulator
tool/run-integration-tests.sh web           # the same in Chrome, but push, over the npm package of this commit
tool/run-ios-unit-tests.sh                  # the iOS side's unit tests (example/ios/RunnerTests)

The integration tests run against the SDK of this repository, not the published one: with SQUIDDY_CORE_SNAPSHOT=true, which the scripts set, the Android side takes <version>-SNAPSHOT from the local Maven repository and the iOS side the package samples/ios/LocalSDK/squiddy-swift, with the XCFramework that Gradle assembles. The scripts build both first, with the same variable, which makes the SDK build that snapshot even on a release tag, and start the kit's fake Squiddy (conformance/start-server.sh), which the test app reaches over cleartext HTTP in its debug build only. The Android side's unit tests run in the test app's Gradle build: SQUIDDY_CORE_SNAPSHOT=true ./gradlew :squiddy_flutter:testDebugUnitTest in example/android, after SQUIDDY_CORE_SNAPSHOT=true ./gradlew :squiddy:publishAndroidPublicationToMavenLocal at the repository's root and flutter build apk --config-only in example.

For the web, tool/run-integration-tests.sh web builds the npm package of this repository (the browser library, assembled as the release packs it) into example/test/web/node_modules, starts the fake Squiddy, which answers a page's CORS checks as Squiddy does, and runs the test app's test/web in Chrome headless: the same conformance cases and bridge tests as on the devices (example/test/support), with an import map that names the package, as an app's index.html does.

0
likes
160
points
129
downloads

Documentation

Documentation
API reference

Publisher

verified publishersquiddy.cloud

Weekly Downloads

Remote configuration, offline cache and app gate from a Squiddy server for Flutter apps on Android, iOS and the web, through the Squiddy SDK itself.

Homepage
View/report issues

Topics

#remote-config #feature-flags #configuration #localization #maintenance-mode

License

Apache-2.0 (license)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on squiddy_flutter

Packages that implement squiddy_flutter