Flutter SDK
Complete integration guide for the e-Ncatch Flutter SDK with comprehensive features for user feedback collection, analytics, and session management
Features and compatibility overview.
Beta version alert
This sdk is in beta version and is bound to change. Usage in production is not recommended.
The encatch Flutter SDK provides a seamless way to integrate user feedback collection into your Flutter applications. This SDK allows you to display customized feedback forms, collect user responses, and submit them to the encatch backend with full support for both traditional navigation and Flutter's new Router API.
Installation
Add the encatch Flutter SDK to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
...other libraries
encatch_flutter: ^latest_version
...other librariesThen run:
flutter pub getInitialization
The SDK must be initialized early in your application lifecycle, typically in your main.dart file, to ensure proper functionality across all screens and widgets.
For standard implementations, initialize the SDK with just your API key and a navigator key. This provides all essential functionality with default configuration settings that work for most applications.
import 'package:flutter/material.dart';
import 'package:encatch_flutter/encatch_flutter.dart';
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Initialize the SDK
encatchFlutter.init(
'<YOUR_PROJECT_API_KEY>',
navigatorKey: navigatorKey,
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey,
navigatorObservers: [encatchFlutter.pathObserver],
home: const HomePage(),
);
}
}For applications requiring custom configuration, the SDK supports advanced initialization options. This approach allows you to specify custom configuration parameters and fine-tune the SDK behavior to match your specific requirements.
import 'package:flutter/material.dart';
import 'package:encatch_flutter/encatch_flutter.dart';
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Initialize with advanced configuration
encatchFlutter.init(
'<YOUR_PROJECT_API_KEY>',
navigatorKey: navigatorKey,
config: encatchConfig(
host: 'https://your-encatch-instance',
identity: UserInfo(
userName: 'user123',
properties: {
'email': 'user@example.com',
'plan': 'premium'
}
),
isAutoCaptureEnabled: true,
themeMode: 'light',
language: 'en',
useRouterAPI: false,
ignoredRoutes: ['/settings', '/privacy']
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey,
navigatorObservers: [encatchFlutter.pathObserver],
home: const HomePage(),
);
}
}encatchConfig Properties:
Prop
Type
UserInfo Class:
class UserInfo {
String userName;
Map<String, dynamic>? properties;
UserInfo({
required this.userName,
this.properties,
});
}For enterprise version
encatchFlutter.init(
'<YOUR_PROJECT_API_KEY>',
navigatorKey: navigatorKey,
config: encatchConfig(
host: 'https://your-encatch-instance'
),
);How to use
User Identification
The identify(String userName, [Map<String, dynamic>? traits]) method is used to identify the current user and fetch personalized configurations based on the user's profile.
Example Usage:
// After successful user authentication
await encatchFlutter.identify('user_123', {
'email': 'user@example.com',
'name': 'John Doe',
'plan': 'premium',
'signup_date': '2025-01-15'
});Use Cases:
- User authentication integration
- Personalized feedback targeting
- User profile synchronization
- Analytics user tracking
Session Management
The SDK provides methods to manage user sessions, each serving different use cases depending on how much user data you want to preserve or reset.
Ends the current session and starts a new one while preserving all user data, identity, and state. This method is useful for creating session boundaries without losing user context.
// End current session but keep user data
await encatchFlutter.stopSession();Use Cases:
- Creating session boundaries
- Preserving user context across session changes
- Session timeout handling
- Application state transitions
Performs a complete reset by starting a new session, clearing user identity, resetting analytics data, and reloading configuration. This returns the SDK to its initial anonymous state.
// Complete session reset
await encatchFlutter.resetSession();Use Cases:
- User logout (best use case)
- Complete session termination
- Clearing all user data and feedback configurations
- Privacy compliance requirements
Triggers
The e-Ncatch Flutter SDK provides comprehensive event tracking capabilities with three distinct approaches: manual feedback control for programmatic trigger management, custom event tracking for business-specific metrics, and navigation tracking for user journey analysis.
Programmatic Feedback Display
Override automatic triggering with manual control over feedback form presentation.
Opens the first feedback from the list of eligible feedbacks.
Example Usage:
// Open first available feedback
await encatchFlutter.openFeedback();Use Cases:
- General feedback collection
- Default feedback trigger
- Quick feedback access
Display a specific feedback form by its unique identifier.
Example Usage:
// Basic usage
await encatchFlutter.openFeedbackById('feedback_config_123');
// With theme and language overrides
await encatchFlutter.openFeedbackById(
'feedback_config_123',
theme: 'dark',
language: 'es'
);Use Cases:
- Programmatic feedback form display
- Integration with existing UI components
- Custom feedback triggers
- A/B testing specific feedback forms
Parameters:
Prop
Type
Display a feedback form by its configured title/name.
Example Usage:
// Open by form title
await encatchFlutter.openFeedbackByName('Product Satisfaction Survey');
// With customization options
await encatchFlutter.openFeedbackByName(
'Feature Feedback',
theme: 'dark',
language: 'fr'
);Use Cases:
- Content-driven feedback display
- User-friendly feedback triggers
- CMS integration scenarios
- Non-technical implementation
Parameters:
Prop
Type
Best Practice: Use feedback IDs for programmatic control and names for content-driven scenarios. IDs are more stable across configuration changes.
Custom Events: Track specific events that are unique to your application's needs and business logic using the trackEvent method.
trackEvent(String eventName, [Map<String, dynamic>? properties])
Use Cases:
- User behavior analytics
- Feature usage tracking
- Conversion funnel analysis
- Custom business metrics
- Application-specific interactions
- A/B test tracking
- User journey mapping
Parameters:
Prop
Type
Example Usage:
// Basic event tracking
await encatchFlutter.trackEvent('page_view');
// E-commerce events
await encatchFlutter.trackEvent('purchase_completed', {
'product_id': 'prod_123',
'amount': 99.99,
'currency': 'USD',
'category': 'electronics',
'quantity': 2,
'payment_method': 'credit_card'
});
// User interaction tracking
await encatchFlutter.trackEvent('button_click', {
'button_id': 'cta-subscribe',
'location': 'hero-section',
'action': 'newsletter_signup'
});
// Feature usage tracking
await encatchFlutter.trackEvent('feature_used', {
'feature': 'advanced_search',
'filters_applied': ['price', 'category', 'rating'],
'results_count': 25,
'search_time': 1.2
});
// Video engagement
await encatchFlutter.trackEvent('video_interaction', {
'video_id': 'tutorial_101',
'action': 'play',
'current_time': 45,
'total_duration': 180,
'quality': '720p'
});
// Form analytics
await encatchFlutter.trackEvent('form_step_completed', {
'form_name': 'onboarding',
'step': 2,
'step_name': 'personal_info',
'time_spent': 120,
'completion_rate': 0.75
});Event Enhancement: The SDK automatically enriches tracked events with:
- Current page path and title
- Session information and user identity
- Device and browser metadata
- Timestamp and user agent
- Geographic location (if available)
UI Customization
Dynamically control the appearance and localization of feedback forms and interfaces.
setTheme(String theme)
Prop
Type
Example Usage:
// Basic theme switching
await encatchFlutter.setTheme('dark'); // Switch to dark theme
await encatchFlutter.setTheme('light'); // Switch to light themeUse Cases:
- Dark mode toggle implementation
- System theme synchronization
- User preference persistence
- Accessibility compliance
setLanguage(String languageCode)
Prop
Type
Example Usage:
// Language localization
await encatchFlutter.setLanguage('es'); // Spanish
await encatchFlutter.setLanguage('fr'); // French
await encatchFlutter.setLanguage('de'); // German
await encatchFlutter.setLanguage('YOUR_ADMIN_CONFIG_LANGUAGE_CODE');Use Cases:
- Internationalization (i18n) implementation
- Multi-language application support
- User language preference persistence
- Browser language detection and fallback
Note: Language changes affect all subsequent feedback forms. You may ideally call this when user switches languages in your application.

