launchTryOnFlow static method

void launchTryOnFlow({
  1. required BuildContext context,
  2. required String apiKey,
  3. required String userId,
  4. required String garmentImageUrl,
  5. String? productId,
  6. String? externalUserId,
  7. Map<String, dynamic>? metadata,
  8. String? modelName = 'fast',
  9. double? version = 1.1,
  10. SnapITTheme theme = const SnapITTheme(),
  11. Future<void> onDownloadImage(
    1. String imageUrl
    )?,
  12. required void onSuccess(
    1. String resultImageUrl,
    2. String generationId
    ),
  13. required void onFailure(
    1. String errorMessage
    ),
})

Opens the Try-On UI experience in the app. Launches a full-screen view where the user can capture/select a photo, triggers upload & try-on generation, and visualizes the results with an interactive slider.

Implementation

static void launchTryOnFlow({
  required BuildContext context,
  required String apiKey,
  required String userId,
  required String garmentImageUrl,
  String? productId,
  String? externalUserId,
  Map<String, dynamic>? metadata,
  String? modelName = 'fast',
  double? version = 1.1,
  SnapITTheme theme = const SnapITTheme(),
  Future<void> Function(String imageUrl)? onDownloadImage,
  required void Function(String resultImageUrl, String generationId)
      onSuccess,
  required void Function(String errorMessage) onFailure,
}) {
  Navigator.of(context).push(
    MaterialPageRoute(
      builder: (context) => TryOnFlowScreen(
        apiKey: apiKey,
        userId: userId,
        garmentImageUrl: garmentImageUrl,
        productId: productId,
        externalUserId: externalUserId,
        metadata: metadata,
        modelName: modelName,
        version: version,
        sdkTheme: theme,
        onDownloadImage: onDownloadImage,
        onSuccess: onSuccess,
        onFailure: onFailure,
      ),
    ),
  );
}