flourish_flutter_sdk 4.0.0
flourish_flutter_sdk: ^4.0.0 copied to clipboard
Flourish SDK for partners integrate.
Changelog #
All notable changes to this plugin will be documented in this file.
4.0.0 22/06/2026 #
Breaking Changes #
ErrorEventnow uses named arguments:ErrorEvent({required code, message})(was positionalErrorEvent(code, message))ErrorEvent.namechanged from'ErrorEvent'to'ERROR'(Event.ERROR)
Added #
- New
onErrorcallback inFlourish.create()for custom handling of web app ERROR events ErrorEvent.fromJson()factory for parsing ERROR postMessage events from the web app- Structured logging via
dart:developerlog()across the entire SDK, filterable byFlourishSDKname in DevTools ERRORcase in JavaScript message handler — web app ERROR events now properly dispatchedhome()now accepts optionalredirectToandresourceIdparameters to deep-link straight into a specific web-app page (e.g. opening a specific partner store from a push notification). Backward compatible —home()with no arguments is unchanged.- Debug-only local-development hooks on
Flourish.create():debugBaseUrl(point the WebView at a local web app, scheme chosen from the URL) anddebugStaticToken(skip the auth backend and use a static token). Honored only in debug builds — release builds always run the normal auth flow. Seeexample/README.mdfor the--dart-defineusage.
Fixed #
- Bug where 403 error handling did not return early, potentially executing both 403 and network error handlers
ErrorEventclass was defined but never instantiated — now properly created for ERROR eventsonErrorEventlistener was defined but never received events — now works as intended
Changed #
- ERROR events from web app now create
ErrorEvent(withcodeandmessage) instead ofGenericEvent - Replaced all
print()calls withdart:developerlog()for production-safe, structured logging- SDK logs use
name: 'FlourishSDK'— filter in DevTools to see only SDK logs - Error logs use
level: 1000, warnings uselevel: 900, info uses default level - Error objects passed via
errorparameter for structured inspection in DevTools - The auth token query param is redacted in URL logs, and JS messages log only the event name (no raw payload) to avoid leaking secrets/PII in production logs
- SDK logs use
Error Scenarios Reference #
Native WebView Errors (handleLoadingPageError)
| Error | Cause | Page |
|---|---|---|
errorCode == 403 |
CloudFront access denied / token error | FlourishTokenErrorPage |
WebResourceErrorType.connect |
TCP connection failed | WebViewLoadErrorPage |
WebResourceErrorType.timeout |
Request timed out (common in high-latency regions) | WebViewLoadErrorPage |
WebResourceErrorType.hostLookup |
DNS resolution failed | WebViewLoadErrorPage |
errorCode == -1009 |
iOS: no internet connection | WebViewLoadErrorPage |
Web App Errors (JavaScript postMessage)
| Event | Cause | Default Behavior |
|---|---|---|
INVALID_TOKEN |
401 auth failure | AuthErrorPage or custom onAuthError |
ERROR |
Network, business logic (422), onboarding, maintenance errors | FlourishTokenErrorPage or custom onError |
ERROR_BACK_BUTTON_PRESSED |
User pressed back on error page | GenericEvent dispatched |
Migration Guide #
No migration required. To add custom error handling:
import 'dart:developer' as developer;
final flourish = await Flourish.create(
uuid: uuid,
secret: secret,
env: Environment.production,
language: Language.spanish,
customerCode: customerCode,
onError: (context, errorEvent) {
developer.log('Error: ${errorEvent.code} - ${errorEvent.message}', name: 'MyApp', level: 1000);
},
);
// Or via stream listener
flourish.onErrorEvent((ErrorEvent event) {
developer.log('Error: ${event.code} - ${event.message}', name: 'MyApp', level: 1000);
});
3.0.0 20/06/2025 #
Changed #
- BREAKING: Refactored Language enum to use getter instead of nullable method
- BREAKING: Replaced String-based URL handling with Uri objects in Endpoint class
- BREAKING: Centralized event names - moved from individual EVENT_NAME constants to Event class constants
- BREAKING: Removed unused native Android and iOS platform plugins
- Improved WebviewContainer URL building with proper Uri manipulation
- Enhanced JavaScript message handling with better error handling and separation of concerns
- Fixed StatefulWidget anti-pattern in WebviewContainer, GenericErrorPageView, and LoadPageErrorView
- Removed field-level state instances that caused memory leaks
- Added proper didUpdateWidget lifecycle handling
- Improved code readability and maintainability across all view components
Fixed #
- Memory leaks from improper state management
- Inconsistent error handling in web resource errors
- Type safety issues with language code handling