encatch_flutter 1.0.0-beta.1
encatch_flutter: ^1.0.0-beta.1 copied to clipboard
Encatch Flutter SDK for in-app feedback and survey collection. Full feature parity with the Encatch React Native SDK.
encatch_flutter #
Official Flutter SDK for Encatch — in-app feedback and survey collection.
Features #
- Initialize the SDK with your API key
- Identify users with traits and secure HMAC verification
- Track custom events and screens
- Display feedback forms in a native WebView overlay with animations
- Offline-resilient retry queue with exponential backoff
- 30-second session ping to maintain engagement sessions
- Pre-fill form responses programmatically
- AI-powered text refinement for long-text questions
- Listen to form lifecycle events
- Full feature parity with the Encatch React Native SDK
Installation #
Add encatch_flutter to your pubspec.yaml:
dependencies:
encatch_flutter: ^1.0.0
Android Setup #
Add internet permission to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
iOS Setup #
No additional setup required. The SDK uses flutter_inappwebview which works out of the box.
Usage #
1. Wrap your app with EncatchProvider #
import 'package:encatch_flutter/encatch_flutter.dart';
void main() {
runApp(
EncatchProvider(
apiKey: 'your-api-key',
child: MyApp(),
),
);
}
2. Identify users #
await Encatch.identifyUser(
'user@example.com',
traits: UserTraits(
set: {'name': 'Jane Doe', 'plan': 'pro'},
),
);
3. Track events #
await Encatch.trackEvent('button_clicked');
4. Track screens #
await Encatch.trackScreen('HomeScreen');
Add EncatchNavigatorObserver for automatic tracking:
MaterialApp(
navigatorObservers: [EncatchNavigatorObserver()],
// ...
)
5. Show a form manually #
await Encatch.showForm('your-form-slug');
6. Listen to form events #
final unsubscribe = Encatch.on((eventType, payload) {
print('Event: $eventType, payload: ${payload.data}');
});
// Later, to stop listening:
unsubscribe();
7. Pre-fill responses #
Encatch.addToResponse('question_id', 'pre-filled value');
await Encatch.showForm('your-form-slug');
Configuration #
EncatchProvider(
apiKey: 'your-api-key',
config: EncatchConfig(
theme: EncatchTheme.system,
debugMode: true,
isFullScreen: false,
apiBaseUrl: 'https://app.encatch.com', // override for self-hosted
),
child: MyApp(),
)
Custom Native Forms #
Use buildSubmitRequest to submit responses from your own native UI:
final request = buildSubmitRequest(
options: BuildSubmitRequestOptions(
formConfigurationId: 'config-id',
triggerType: TriggerType.manual,
),
responses: [
NativeFormResponse(questionId: 'q1', type: 'rating', value: '5'),
NativeFormResponse(questionId: 'q2', type: 'short_answer', value: 'Great!'),
],
);
await Encatch.submitForm(request);
License #
MIT License. See LICENSE for details.