diff --git a/packages/stripe_checkout/lib/stripe_checkout.dart b/packages/stripe_checkout/lib/stripe_checkout.dart index cb21e9aee..43198bb7f 100644 --- a/packages/stripe_checkout/lib/stripe_checkout.dart +++ b/packages/stripe_checkout/lib/stripe_checkout.dart @@ -1,9 +1,10 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stripe_checkout/src/platforms/checkout.dart' show CheckoutResponse; -import 'src/platforms/stripe_checkout_web.dart' as stripe; +import 'src/platforms/checkout.dart'; +import 'src/platforms/stripe_checkout.dart' + if (dart.library.js) 'src/platforms/stripe_checkout_web.dart' as stripe; Future redirectToCheckout({ required BuildContext context, @@ -13,17 +14,12 @@ Future redirectToCheckout({ String? successUrl, String? canceledUrl, }) { - if (kIsWeb) { - return stripe.redirectToCheckout( - context: context, - sessionId: sessionId, - publishableKey: publishableKey, - stripeAccountId: stripeAccountId, - successUrl: successUrl, - canceledUrl: canceledUrl, - ); - } else { - throw UnsupportedError( - 'redirectToCheckout is not supported on this platform'); - } + return stripe.redirectToCheckout( + context: context, + sessionId: sessionId, + publishableKey: publishableKey, + stripeAccountId: stripeAccountId, + successUrl: successUrl, + canceledUrl: canceledUrl, + ); }