Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank CardField Widget on Android #1594

Closed
blk-raffy opened this issue Jan 11, 2024 · 1 comment
Closed

Blank CardField Widget on Android #1594

blk-raffy opened this issue Jan 11, 2024 · 1 comment
Labels
needs triage Needs triage

Comments

@blk-raffy
Copy link

blk-raffy commented Jan 11, 2024

Description

The Card Field widget is not shown as expected. The console gives me "lateinit property stripeSdk has not been initialized" but I'm waiting correctly the execution of the WidgetsFlutterBinding.ensureInitialized(), I'm using the FlutterFragmentActivityinstead of the FlutterActivity, I'm initializing the stripePublishableKey and I have followed the setup guide. Idk what to do.

Sources:

Guide I was following from: https://docs.page/flutter-stripe/flutter_stripe/card_field
Maybe related: #68
Other issue with blank widget: #1383

Flutter

Dependencies
json_annotation: ^4.8.1
cupertino_icons: ^1.0.2
flutter_svg: ^2.0.0+1
intl: any
flutter_bloc: ^8.1.1
equatable: ^2.0.5
bloc: ^8.1.0
formz: ^0.6.0
mobile_scanner: ^3.2.0
path_provider: ^2.0.11
image_picker: ^0.8.6
mapbox_search: ^3.0.1+2
flutter_dotenv: ^5.0.2
geolocator: ^9.0.2
shared_preferences: ^2.0.15
carousel_slider: ^4.2.1
skeletons: ^0.0.3
url_launcher: ^6.1.10
cached_network_image: ^3.2.3
fl_chart: ^0.61.0
localstorage: ^4.0.0+1
image: any
sentry_flutter: ^7.5.2
flutter_secure_storage: ^8.0.0
app_tracking_transparency: ^2.0.4
package_info_plus: ^4.0.2
upgrader: ^7.1.0
go_router: ^10.0.0
easy_localization: ^3.0.2
share_plus: ^7.0.2
file_picker: ^5.2.11
restart_app: ^1.2.1
path_drawing: any
in_app_update: ^4.2.2
in_app_review: ^2.0.8
# tutorial_coach_mark: ^1.2.11
firebase_core: ^2.19.0
firebase_messaging: ^14.7.1
firebase_remote_config: ^4.3.5
firebase_analytics: ^10.7.1
flutter_local_notifications: ^10.0.0
flutter_stripe: ^10.0.0
flutter_launcher_icons: ^0.13.1
flutter_native_splash: ^2.3.0
Error log

image

E/flutter (15962): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, lateinit property stripeSdk has not been initialized, null, kotlin.UninitializedPropertyAccessException: lateinit property stripeSdk has not been initialized
E/flutter (15962): at com.flutter.stripe.StripeAndroidPlugin.getStripeSdk(StripeAndroidPlugin.kt:34)
2
E/flutter (15962): at com.flutter.stripe.StripeAndroidPlugin$onAttachedToEngine$1.invoke(StripeAndroidPlugin.kt:59)
E/flutter (15962): at com.flutter.stripe.StripeSdkCardPlatformView.(StripeSdkCardPlatformView.kt:27)
E/flutter (15962): at com.flutter.stripe.StripeSdkCardPlatformViewFactory.create(StripeSdkCardPlatformViewFactory.kt:24)
E/flutter (15962): at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:520)
E/flutter (15962): at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:165)
E/flutter (15962): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
E/flutter (15962): at E/flutter (15962): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
E/flutter (15962): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/flutter (15962): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (15962): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/flutter (15962): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (15962): at android.os.Handler.handleCallback(Handler.java:942)
E/flutter (15962): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (15962): at android.os.Looper.loopOnce(Looper.java:240)
E/flutter (15962): at android.os.Looper.loop(Looper.java:351)
E/flutter (15962): at android.app.ActivityThread.main(ActivityThread.java:8377)
E/flutter (15962): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (15962): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
E/flutter (15962): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
E/flutter (15962): )
E/flutter (15962): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter (15962): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18)
E/flutter (15962):
E/flutter (15962): #2 ExpensiveAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1081:5)
E/flutter (15962):
E/flutter (15962): #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:804:5)
E/flutter (15962):
E/flutter (15962):

flutter doctor -v
[√] Flutter (Channel stable, 3.16.5, on Microsoft Windows [Versione 10.0.22621.3007], locale it-IT)
    • Flutter version 3.16.5 on channel stable at E:\programmi\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (3 weeks ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at E:\programmi\AndroidStudioSdk
    • Platform android-34, build-tools 33.0.2
    • ANDROID_HOME = C:\Program Files (x86)\Android\android-sdk
    • Java binary at: E:\programmi\AndroidStudio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
    • Visual Studio at E:\programmi\VisualStudio
    • Visual Studio Community 2022 version 17.7.34031.279
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.2)
    • Android Studio at E:\programmi\AndroidStudio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = E:\programmi\AndroidStudio
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] Connected device (4 available)
    • RMX3521 (mobile)  • 7251b54b • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows  • windows-x64    • Microsoft Windows [Versione 10.0.22621.3007]
    • Chrome (web)      • chrome   • web-javascript • Google Chrome 120.0.6099.130
    • Edge (web)        • edge     • web-javascript • Microsoft Edge 120.0.2210.121

[√] Network resources
    • All expected network resources are available.

• No issues found!

main.dart

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((_) {
      _trackingTransparencyRequest();
      _firebaseHandler();
      _initializeStripe();
    });

}

Future<void> _initializeStripe() async {
  Stripe.publishableKey =
      const String.fromEnvironment('STRIPE_PUBLISHABLE_KEY');

  await Stripe.instance.applySettings();
}

Note: already try to write Stripe.publishableKey = const String.fromEnvironment('STRIPE_PUBLISHABLE_KEY'); under the WidgetsFlutterBinding instead of inside the addPostFrameCallback and it changes nothing

MainActivity.tk

package com.mitbee.demopackage

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() {
}

Note: even if i remove the import io.flutter.embedding.android.FlutterActivity it does not work

I've seen other issues which says to turn off the dark mode, well i don't have the darkmode enabled and the widget still blank:

photo_2024-01-11_16-47-07

Bottom Sheet code

showModalBottomSheet(
  isScrollControlled: true,
  context: context,
  builder: (context) => Container(
        padding: const EdgeInsets.all(Dimensions.dim16),
        child: Column(
          children: [
            const Text("This should be the Card Field"),
            CardField(
              onCardChanged: (card) {
                Debug.info("aaaaaaaaaa");
              },
            )
          ],
        ),
      ));

Note: If I switch from the CardField to the CardFormField it does not change nothing

@blk-raffy blk-raffy added the needs triage Needs triage label Jan 11, 2024
@remonh87
Copy link
Member

duplicate of #1383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Needs triage
Projects
None yet
Development

No branches or pull requests

2 participants