Skip to content

fix: change initCustomerSheet return type to Future<void>#2292

Merged
remonh87 merged 3 commits into
flutter-stripe:mainfrom
realmeylisdev:fix/init-customer-sheet-return-type-2283
Jan 14, 2026
Merged

fix: change initCustomerSheet return type to Future<void>#2292
remonh87 merged 3 commits into
flutter-stripe:mainfrom
realmeylisdev:fix/init-customer-sheet-return-type-2283

Conversation

@realmeylisdev

Copy link
Copy Markdown
Contributor

Summary

Fixes #2283: The initCustomerSheet method has a misleading return type.

Problem

  • Return type was Future<CustomerSheetResult?> suggesting payment data might be returned
  • Actual behavior: always returns null on success, throws exception on error
  • Doesn't match React Native SDK which uses Promise<{ error?: StripeError }>

Solution

  • Change return type to Future<void>
  • Simplify implementation to only check for errors
  • Add doc comment clarifying it throws StripeException on failure

Changes

  • stripe_platform_interface.dart - Updated interface signature
  • method_channel_stripe.dart - Simplified implementation
  • stripe.dart - Updated public facade
  • web_stripe.dart - Updated web implementation

Breaking Change

This is a minor breaking change for any code that was capturing the (always null) return value. The fix is simple - just remove the variable assignment since the method now returns void.

Before:

final result = await Stripe.instance.initCustomerSheet(...); // result always null

After:

await Stripe.instance.initCustomerSheet(...);

Test plan

  • All existing tests pass (25/25 method channel tests)
  • Manual verification on iOS
  • Manual verification on Android

…ripe#2283)

The method always returned null on success, making the CustomerSheetResult?
return type misleading. This aligns with React Native SDK behavior.

Changes:
- Return type: Future<CustomerSheetResult?> → Future<void>
- Simplified implementation to only check for errors
- Added doc comment about throwing StripeException on failure
@jonasbark jonasbark requested a review from remonh87 December 29, 2025 13:34
- Replace dart:js with dart:js_interop in loader tests
- Add dart:js_interop_unsafe for bracket operator support
- Update context to globalContext
- Fix example .env import path

@remonh87 remonh87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@remonh87 remonh87 merged commit fbed928 into flutter-stripe:main Jan 14, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading return type for initCustomerSheet

2 participants