insightdive_sdk 0.5.0 copy "insightdive_sdk: ^0.5.0" to clipboard
insightdive_sdk: ^0.5.0 copied to clipboard

Flutter SDK for Insightdive in-app surveys. Modal bottom-sheet or inline widget — embed anywhere, stream lifecycle events, zero user identifiers.

example/lib/main.dart

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

void main() {
  // Configure once at app startup.
  // Replace the values below with your tenant slug, survey slug, and API key
  // found in your Insightdive admin (Settings → API).
  Insightdive.configure(
    tenant: 'acme',
    survey: 'onboarding',
    apiKey: 'ik_…',
    productVersion: '1.0.0',
    productIdentifier: 'example-app',
  );

  runApp(const ExampleApp());
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Insightdive SDK example',
      theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.blue),
      home: const _Home(),
    );
  }
}

class _Home extends StatefulWidget {
  const _Home();

  @override
  State<_Home> createState() => _HomeState();
}

class _HomeState extends State<_Home> {
  String? _lastResult;
  late final _eventSub = Insightdive.events.listen((FeedbackEvent event) {
    debugPrint('[insightdive] $event');
  });

  @override
  void dispose() {
    _eventSub.cancel();
    super.dispose();
  }

  Future<void> _openFeedback() async {
    // show() opens a modal bottom sheet and resolves when it is closed.
    final result = await Insightdive.show(context);
    if (!mounted) return;
    setState(() {
      _lastResult = switch (result.status) {
        FeedbackStatus.completed =>
          'Completed in ${result.duration.inSeconds}s — '
          'submission ${result.submissionId ?? '(?)'}',
        FeedbackStatus.dismissed =>
          'Dismissed after ${result.duration.inSeconds}s',
      };
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Insightdive SDK example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            FilledButton.icon(
              onPressed: _openFeedback,
              icon: const Icon(Icons.feedback_outlined),
              label: const Text('Give feedback'),
            ),
            const SizedBox(height: 24),
            if (_lastResult != null)
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 24),
                child: Text(
                  _lastResult!,
                  textAlign: TextAlign.center,
                  style: Theme.of(context).textTheme.bodyMedium,
                ),
              ),
          ],
        ),
      ),
    );
  }
}
0
likes
0
points
414
downloads

Documentation

Documentation

Publisher

unverified uploader

Weekly Downloads

Flutter SDK for Insightdive in-app surveys. Modal bottom-sheet or inline widget — embed anywhere, stream lifecycle events, zero user identifiers.

Homepage
Repository (GitHub)
View/report issues

Topics

#feedback #survey #nps #csat #webview

License

unknown (license)

Dependencies

flutter, webview_flutter

More

Packages that depend on insightdive_sdk