flutter_stripe icon indicating copy to clipboard operation
flutter_stripe copied to clipboard

Uncaught Unsupported operation: Platform._operatingSystem when deployed to firebase hosting for web

Open jeedy20 opened this issue 1 year ago • 20 comments

I get an Uncaught Unsupported operation: Platform._operatingSystem after i deploy my flutter web app to firebase hosting and its stucked in the splash screen any solution to this?. I think this is the cause of the error in my main.dart page. await dotenv.load(fileName: ".env"); Stripe.publishableKey = dotenv.env['StripePublishableKey']!; Stripe.merchantIdentifier = 'merchant.flutter.stripe.test'; Stripe.urlScheme = 'flutterstripe'; await Stripe.instance.applySettings();

jeedy20 avatar Jan 27 '24 20:01 jeedy20

Getting same, any solution you found?

jeffysmak avatar Jan 28 '24 11:01 jeffysmak

Nothing yet

jeedy20 avatar Jan 28 '24 11:01 jeedy20

Can you fill in the required info of the issue? I need a full stacktrace + output of flutter doctor.

remonh87 avatar Jan 29 '24 16:01 remonh87

Untitled

[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22000.2538], locale en-NG) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.33) X The current Visual Studio installation is incomplete. Please use Visual Studio Installer to complete the installation or reinstall Visual Studio. [!] Android Studio (version 2021.3) X Unable to determine bundled Java version. [√] Android Studio (version 2023.1) [√] VS Code (version 1.85.2) [√] Connected device (4 available) [√] Network resources These are what you requested for

jeedy20 avatar Jan 29 '24 18:01 jeedy20

i implemented this plugin's basic of functionality my self and full fill my requirements. with stripe js (client side) card-field element, tested on firebase works fine.

jeffysmak avatar Jan 30 '24 20:01 jeffysmak

@jeedy20 I cannot see in the stack trace that it has to do something with our sdk. What kind of widget are you using ?

remonh87 avatar Feb 04 '24 13:02 remonh87

@remonh87 i have also same problem.Platform._operatingSystem in flutter web [√] Flutter (Channel stable, 3.16.3, on Microsoft Windows [Version 10.0.22000.2538], locale en-NG) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.33) X The current Visual Studio installation is incomplete. Please use Visual Studio Installer to complete the installation or reinstall Visual Studio. [!] Android Studio (version 2021.3) X Unable to determine bundled Java version. [√] Android Studio (version 2023.1) [√] VS Code (version 1.85.2) [√] Connected device (4 available) [√] Network resources

Vigneshb799 avatar Feb 06 '24 12:02 Vigneshb799

@jeedy20 I cannot see in the stack trace that it has to do something with our sdk. What kind of widget are you using ?

Payment Element sir.

jeedy20 avatar Feb 06 '24 21:02 jeedy20

I was unable to reproduce this in the example app. Can you provide a small example repo / code?

jonasbark avatar Feb 07 '24 07:02 jonasbark

I had been experiencing the same issue then realised that I forgot to add flutter_stripe_web: ^5.0.0 to the dependencies. flutter_stripe and flutter_stripe_web, both are required to work on flutter web.

This worked for me! Hope this helps someone.

richardnovasnw avatar Feb 08 '24 09:02 richardnovasnw

I had been experiencing the same issue then realised that I forgot to add flutter_stripe_web: ^5.0.0 to the dependencies. flutter_stripe and flutter_stripe_web, both are required to work on flutter web.

This worked for me! Hope this helps someone.

i added both dependencies flutter_stripe and flutter_stripe_web but not worked for me 🤨. it works fine in debug mode but when app deployed to firebase hosting than its not.

jeffysmak avatar Feb 10 '24 10:02 jeffysmak

Yeah. Any solution yet?

jeedy20 avatar Feb 13 '24 19:02 jeedy20

does the same happen when you run flutter run --release ?

remonh87 avatar Feb 13 '24 20:02 remonh87

@remonh87 I'm having the same issue, but as long as I'm working locally everything works. So, it doesn't happen the same when I run flutter run --release

asdico avatar Feb 17 '24 14:02 asdico

I looked into it and this is a flutter issue and not something from this sdk: https://github.com/flutter/flutter/issues/36126

remonh87 avatar Mar 02 '24 10:03 remonh87

So what could be the solution?

jeedy20 avatar Mar 02 '24 10:03 jeedy20

@jeedy20 I solved the issue upgrading both Flutter and the SDKs version.

flutter --version

Flutter 3.19.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bae5e49bc2 (2 weeks ago) • 2024-02-13 17:46:18 -0800
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1

Flutter SKDs version:

  flutter_stripe: ^10.0.0
  flutter_stripe_web: ^5.0.0

Try this out, it worked for me.

asdico avatar Mar 02 '24 10:03 asdico

Okay thanks alot

jeedy20 avatar Mar 02 '24 11:03 jeedy20

Since I can not upgrade to Flutter 3.19 I made an hacky edit in method_channel_stripe

StripePlatform create() => kIsWeb?MethodChannelStripe(
    methodChannel: const MethodChannel(
      'flutter.stripe/payments',
      JSONMethodCodec(),
    ),
    platformIsIos: false,
    platformIsAndroid: false,
  ):MethodChannelStripe(
        methodChannel: const MethodChannel(
          'flutter.stripe/payments',
          JSONMethodCodec(),
        ),
        platformIsIos: Platform.isIOS,
        platformIsAndroid: Platform.isAndroid,
      );

andrezanna avatar Mar 02 '24 11:03 andrezanna