insito_flutter 0.2.2 copy "insito_flutter: ^0.2.2" to clipboard
insito_flutter: ^0.2.2 copied to clipboard

In-app micro-surveys for Flutter — NPS, ratings, and multi-question flows with theming, offline queueing, logic branching, and automatic screen tracking.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:insito_flutter/insito_flutter.dart';

import 'insito.dart';
import 'screens/demo_bank_shell.dart';
import 'theme/theme_controller.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await ensureInsitoReady();
  runApp(DemoBankApp(themeController: ThemeController()));
}

class DemoBankApp extends StatefulWidget {
  const DemoBankApp({super.key, required this.themeController});

  final ThemeController themeController;

  @override
  State<DemoBankApp> createState() => _DemoBankAppState();
}

class _DemoBankAppState extends State<DemoBankApp> with WidgetsBindingObserver {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    widget.themeController.addListener(_onThemeChanged);
    startInsitoSession();
    whenInsitoReady().then((_) => MicroSurvey.trigger('app_opened'));
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    widget.themeController.removeListener(_onThemeChanged);
    super.dispose();
  }

  void _onThemeChanged() => setState(() {});

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      whenInsitoReady().then((_) => MicroSurvey.trigger('app_opened'));
    }
  }

  @override
  Widget build(BuildContext context) {
    final theme = widget.themeController;
    final isDark = theme.isDark;

    return InsitoProvider(
      appearance: isDark ? InsitoAppearance.dark : InsitoAppearance.light,
      child: MaterialApp(
        title: 'Demo Bank',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          useMaterial3: true,
          brightness: isDark ? Brightness.dark : Brightness.light,
          scaffoldBackgroundColor: theme.colors.background,
          colorScheme: ColorScheme.fromSeed(
            seedColor: theme.colors.accent,
            brightness: isDark ? Brightness.dark : Brightness.light,
          ),
        ),
        home: DemoBankShell(themeController: theme),
      ),
    );
  }
}
0
likes
150
points
272
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

In-app micro-surveys for Flutter — NPS, ratings, and multi-question flows with theming, offline queueing, logic branching, and automatic screen tracking.

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

device_info_plus, flutter, http, shared_preferences

More

Packages that depend on insito_flutter