insito_flutter 0.1.0
insito_flutter: ^0.1.0 copied to clipboard
In-app micro-surveys for Flutter apps
insito_flutter #
In-app micro-surveys for Flutter apps. A Dart/Flutter port of the
@insito/react-native SDK with full behavioural
parity: the same /v1/sdk/* API, offline queue, identify cache, screen-map
batching, per-install trigger counters, theming + Brand Kit, dark mode, logic
branching, welcome/end screens, and autosave.
Install #
Add the dependency (from a published version or a path/git source while this package is private):
dependencies:
insito_flutter: ^0.1.0
Then:
flutter pub get
Quick start #
import 'package:flutter/material.dart';
import 'package:insito_flutter/insito_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await MicroSurvey.init(const InsitoConfig(apiKey: 'proj_xxx'));
await MicroSurvey.identify(const UserProperties(userId: 'user-123'));
runApp(
InsitoProvider(
child: MaterialApp(
navigatorObservers: [InsitoNavigatorObserver()],
home: const HomeScreen(),
),
),
);
}
Trigger a survey at a key moment:
await MicroSurvey.trigger('checkout_completed');
Identify with properties #
await MicroSurvey.identify(
const UserProperties(
userId: 'user-123',
platform: 'ios',
appVersion: '2.4.0',
properties: {'plan': 'pro', 'transactionsThisMonth': 12},
),
);
Events (pub/sub) #
MicroSurvey.on returns an unsubscribe function:
final off = MicroSurvey.on(InsitoEvent.surveyCompleted, (payload) {
debugPrint('completed ${payload.surveyId}');
});
// later
off();
Available events: initialized, surveyShown, surveyDismissed,
surveyCompleted, responseSubmitted, responseQueued, responseFailed,
screenTracked, screenMapFlushed, error.
Theming #
Pick a preset and optionally override tokens. A project Brand Kit (delivered
with the survey) layers between the preset and your init overrides
(preset < brandConfig < init overrides). Dark mode is auto-detected from the
device (override via InsitoProvider(appearance: ...)).
await MicroSurvey.init(
const InsitoConfig(
apiKey: 'proj_xxx',
themePreset: ThemePreset.rounded,
themeOverrides: InsitoThemeOverrides(
colors: InsitoColorsOverride(primary: Color(0xFF7C3AED)),
),
),
);
Screen tracking #
Add InsitoNavigatorObserver() to your MaterialApp.navigatorObservers. Named
routes report their RouteSettings.name; each new screen records a visit and
fires screen_viewed:<name> once a user is identified.
Example #
See example/ for a runnable Material 3 app (flutter run from
that directory) demonstrating init, identify, triggering, and screen tracking.
API surface #
MicroSurvey.init/identify/trigger/evaluate/submitResponse/savePartialProgress/dismissSurvey/on/off/recordScreenVisit.InsitoProvider— mounts the survey modal above your app.InsitoNavigatorObserver— automatic screen tracking.- Types:
InsitoConfig,UserProperties,ActiveSurvey,SurveyQuestion,Answer,QuestionType,SdkState,InsitoEvent, theme types + presets.
Development #
flutter pub get
flutter analyze
flutter test
Unit tests cover the HTTP client (retry/timeout/never-throw), offline queue (FIFO/cap), logic evaluator (branching), theme (deep-merge + Brand Kit mapping), event bus, and labels.
Manual follow-ups #
These steps are intentionally left manual:
- Run
flutter pub get,flutter analyze, andflutter testto confirm a clean checkout on your toolchain. - Create the repository (e.g.
https://github.com/VJiri/insito-flutter) and push this package. - Publish to pub.dev (
flutter pub publish) once the repo and CI are set up.
License #
MIT — see LICENSE.