Advanced Integration

This guide covers advanced SDK features for customization and extension.

Custom Widgets

Register your own Flutter widgets to use in Digia Studio.

When to Use

  • Native Operations: When you need to perform native Flutter/platform operations (camera, GPS, device sensors)

  • Third-party Libraries: When using Flutter packages not available in Digia UI

  • Complex UI Logic: When you need custom animations, gestures, or state management

  • Missing Components: When Digia UI doesn't have the specific widget you need

  • Performance: When native widgets perform better for specific use cases

When NOT to Use

  • Basic UI: For simple buttons, text, images - use Digia UI directly

  • Standard Components: For common widgets already in Digia UI

  • Simple Layouts: For basic containers, columns, rows - use Digia UI

Implementation

Step 1: Define Props Class

Note: This example shows a basic custom widget. In practice, prefer Digia UI components for simple styling needs. Only use custom widgets when Digia UI cannot provide the required functionality or performance.

Step 2: Create Widget Class

Step 3: Register Widget

💡 See custom-widgets.md for complete guide.

Environment Variables

Pass runtime configuration to Digia UI pages.

When to Use

  • Different API endpoints per environment

  • Feature flags

  • App version info

  • Theme configuration

Usage

or you can also set it by these two functions:

Access in Digia Studio:

Analytics Integration

Track user interactions from Digia UI pages.

When to Use

  • Track page views and events

  • Monitor user behavior

  • Send analytics to Firebase, Mixpanel, etc.

Implementation

Usage in main.dart:

Now events from Digia Studio actions will be tracked automatically.

PostMessage Handling (Digia to Native)

Handle messages sent from Digia UI pages to native Flutter code using the callExternalMethod action.

When to Use

  • Trigger native functionality from Digia UI (navigation, external URLs, logging)

  • Send data from Digia forms to native processing

  • Execute platform-specific operations

Implementation

Step 1: Use DigiaMessageHandlerMixin

If you want to handle messages from Digia UI, use the DigiaMessageHandlerMixin and register handlers with addMessageHandler():

Step 2: Register Handler in App

Step 3: Use in Digia Studio

In Digia Studio, use the callExternalMethod action

Best Practices

Message Naming

  • Use snake_case for channel names: start_payment, share_product

  • Be descriptive but concise

  • Group related messages: payment_*, user_*, navigation_*

Data Handling

  • Always check payload type and structure

  • Provide fallbacks for missing data

  • Use safe type casting

Network Configuration

Customize network behavior.

When to Use

  • Custom headers

  • SSL certificate pinning

  • Proxy configuration

  • Timeout customization

Implementation

Advanced State Management

Stream-Based Updates

When to use: Real-time UI updates from native code

StreamBuilder Pattern

When to use: Reactive UI components

Multi-Environment Setup

When to use: Different configs for dev, staging, production

Run different environments:

Best Practices

Security

  • ✅ Store access keys securely (never in code for production)

  • ✅ Use environment variables for sensitive data

  • ✅ Validate data from Digia UI pages

Performance

  • ✅ Use CacheFirstStrategy for faster app startup

  • ✅ Minimize global state size

  • ✅ Cancel stream subscriptions in dispose()

State Management

  • ✅ Use meaningful state keys (user.profile not data1)

  • ✅ Structure complex data with nested objects

  • ✅ Provide fallbacks for null values

Testing

  • ✅ Test with different flavors (debug, staging, release)

  • ✅ Test offline scenarios with LocalFirstStrategy

  • ✅ Mock DUIAppState for unit tests

Next Steps

Last updated