tapsurvey_flutter 0.1.1 copy "tapsurvey_flutter: ^0.1.1" to clipboard
tapsurvey_flutter: ^0.1.1 copied to clipboard

A Flutter library for integrating AI-powered surveys into your applications. TapSurvey provides a conversational survey experience with dynamic, adaptive questioning based on user responses.

TapSurvey Flutter SDK #

A powerful Flutter SDK for integrating AI-powered surveys into your Flutter applications. TapSurvey provides a conversational survey experience with dynamic, adaptive questioning based on user responses.

Features #

  • 🤖 AI-powered conversational surveys
  • 📱 Native Flutter implementation
  • 💬 Real-time adaptive questioning
  • 📊 Seamless data collection
  • 🔄 Simple integration with just a few lines of code
  • 🎨 Customizable UI that matches your app's style

Installation #

dependencies:
  tapsurvey_flutter: ^0.1.0

Or add the package directly from your git repository:

dependencies:
  tapsurvey_flutter:
    git:
      url: https://github.com/yourusername/tapsurvey-flutter.git
      ref: main

Then run:

flutter pub get

Quick Start #

1. Import the SurveyWindow widget #

import 'package:tapsurvey_flutter/tapsurvey_flutter.dart';

2. Implement the survey in your widget #

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

class SurveyScreen extends StatefulWidget {
  const SurveyScreen({Key? key}) : super(key: key);

  @override
  State<SurveyScreen> createState() => _SurveyScreenState();
}

class _SurveyScreenState extends State<SurveyScreen> {
  bool _surveyVisible = false;
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('TapSurvey Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                setState(() {
                  _surveyVisible = true;
                });
              },
              child: const Text('Open Survey'),
            ),
            if (_surveyVisible)
              SurveyWindow(
                open: _surveyVisible,
                onClose: () {
                  setState(() {
                    _surveyVisible = false;
                  });
                },
                appToken: 'YOUR_APP_TOKEN',
                surveyId: 'YOUR_SURVEY_ID',
                userId: 'USER_ID', // Provide a unique ID for the user
              ),
          ],
        ),
      ),
    );
  }
}

API Reference #

SurveyWindow Widget #

The main widget that renders the AI-powered survey interface.

Properties

Property Type Required Description
open bool Yes Controls the visibility of the survey modal
onClose VoidCallback? Yes Callback function to handle closing the survey
appToken String Yes Your TapSurvey application token from the dashboard
surveyId String Yes The ID of the specific survey to display
userId String Yes Unique identifier for the user taking the survey
debug bool No Enable debug mode (defaults to false)
onSubmit VoidCallback? No Optional callback when survey is completed successfully

Survey Flow #

  1. Initialization: When the open property becomes true, the survey loads the first question.
  2. Conversation: The AI asks questions and presents them in a chat-like interface.
  3. Adaptation: Based on user responses, the AI dynamically adjusts follow-up questions.
  4. Completion: Upon survey completion, a success message is shown and onClose is available to dismiss the modal.

Example with User Tracking #

import 'package:flutter/material.dart';
import 'package:tapsurvey_flutter/tapsurvey_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';

class SurveyPage extends StatefulWidget {
  const SurveyPage({Key? key}) : super(key: key);

  @override
  State<SurveyPage> createState() => _SurveyPageState();
}

class _SurveyPageState extends State<SurveyPage> {
  bool _surveyVisible = false;
  String? _userId;

  @override
  void initState() {
    super.initState();
    _getUserId();
  }

  Future<void> _getUserId() async {
    final prefs = await SharedPreferences.getInstance();
    String? userId = prefs.getString('user_id');
    
    if (userId == null) {
      userId = 'user_${DateTime.now().millisecondsSinceEpoch}';
      await prefs.setString('user_id', userId);
    }
    
    setState(() {
      _userId = userId;
    });
  }

  void _handleSurveyComplete() {
    debugPrint('Survey completed');
    // Send completion analytics or trigger other actions
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Survey Example'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            setState(() {
              _surveyVisible = true;
            });
          },
          child: const Text('Give Feedback'),
        ),
      ),
      // Only show survey when userId is loaded and survey should be visible
      bottomSheet: (_userId != null && _surveyVisible) 
        ? SurveyWindow(
            open: _surveyVisible,
            onClose: () {
              setState(() {
                _surveyVisible = false;
              });
            },
            onSubmit: _handleSurveyComplete,
            appToken: 'YOUR_APP_TOKEN',
            surveyId: 'YOUR_SURVEY_ID',
            userId: _userId!,
          )
        : null,
    );
  }
}

Getting Your App Token and Survey ID #

  1. Create an account at TapSurvey Dashboard
  2. Create a new survey in the dashboard
  3. Go to the Integration section to find your App Token
  4. Copy the Survey ID from the survey settings

Best Practices #

  • Always provide a unique and persistent userId to maintain survey continuity
  • Open surveys at appropriate moments in the user journey
  • Use the onSubmit callback to track survey completion
  • Test your integration in debug mode before deploying to production

License #

MIT


For more information, visit tapsurvey.io

0
likes
115
points
11
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter library for integrating AI-powered surveys into your applications. TapSurvey provides a conversational survey experience with dynamic, adaptive questioning based on user responses.

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on tapsurvey_flutter