flutter-plugin
flutter-plugin copied to clipboard
Issue with Google Pay Button Rendering in Light Theme and Theme.AppCompat Error
Description: There seems to be an issue when using the Google Pay Button with the pay package in Flutter. The button does not render correctly when using the light theme, and there are errors related to the Theme.AppCompat.
Steps to Reproduce:
Add the pay package and necessary dependencies to the Flutter project. Run the app and observe the rendering issue and log errors. Expected Behavior: The Google Pay Button should render correctly with the light theme applied.
Observed Behavior: The button shows graphical glitches or does not render correctly. Additionally, there are errors in the logs related to using Theme.AppCompat.
Additional Information:
The error message indicates an issue with the attribute at index 0, related to the Theme.AppCompat. Please investigate this issue to determine the root cause and provide a fix or workaround. Thank you.
Additional Information:
pay package version: pay: ^2.0.0
flutter --version Flutter 3.22.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision b0850beeb2 (3 weeks ago) • 2024-07-16 21:43:41 -0700 Engine • revision 235db911ba Tools • Dart 3.4.4 • DevTools 2.34.3
Android Studio Koala | 2024.1.1 Patch 1 Build #AI-241.18034.62.2411.12071903, built on July 10, 2024 Runtime version: 17.0.11+0--11852314 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11.0 GC: G1 Young Generation, G1 Old Generation Memory: 4058M Cores: 24 Registry: debugger.new.tool.window.layout=true ide.experimental.ui=true
Relevant code:
Center( child: GooglePayButton( paymentConfiguration: paymentConfig, key: Key(selectedIndex.toString()),
paymentItems: [
PaymentItem(
label: 'Total',
amount: (() {
final price = packages![selectedIndex].price.toString();
return price;
})(),
status: PaymentItemStatus.final_price,
)
],
theme: GooglePayButtonTheme.light,
type: GooglePayButtonType.pay,
margin: const EdgeInsets.only(top: 15.0),
onPressed: () {
setState(() {});
return;
},
onPaymentResult: (result) async {
try {
String res = result.toString();
log("Payment result: $res");
String tokenJson = result['methodData']['tokenData']['token'];
Map<String, dynamic> tokenData = jsonDecode(tokenJson);
String tokenId = tokenData['id'];
int amount = convertToIntMultiplyBy100(packages![selectedIndex].price);
String tokenDesc = result['methodData']['description'];
await processStripePayment(
tokenId,
amount,
packages![selectedIndex].points,
tokenDesc,
);
} catch (e, s) {
userFeedback.showFeedbackMessage("Payment Error", e.toString());
handleError(e, s, 'Payment Error');
}
},
onError: (error) {
log("Payment error: $error");
},
loadingIndicator: const Center(
child: CircularProgressIndicator(),
),
), ),
Manifest Configuration:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:enableOnBackInvokedCallback="true"
android:usesCleartextTraffic="true"
android:label="xpt"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/Theme.AppCompat.Light"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true"/>
</application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
</queries>
Dependencies:
dependencies { implementation 'com.android.support:multidex:1.0.3' implementation "androidx.multidex:multidex:2.0.1" implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.compose.material:material:1.6.8' implementation 'com.google.android.gms:play-services-wallet:19.4.0' implementation 'com.google.android.gms:play-services-base:18.5.0' implementation 'com.stripe:stripe-android:20.37.4' implementation(platform("com.google.firebase:firebase-bom:33.1.2")) implementation("com.google.firebase:firebase-crashlytics-ndk") implementation("com.google.firebase:firebase-analytics") }
LOG Output
E/ThemeUtils(32156): View class android.support.v7.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
E/ThemeUtils(32156): View class com.google.android.material.imageview.ShapeableImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
W/ResourcesCompat(32156): Failed to inflate ColorStateList, leaving it to the framework
W/ResourcesCompat(32156): java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7b040084 a=-1}, theme={InheritanceMap=[id=0x7b1100abcom.google.android.gms:style/PayButtonLightTheme], Themes=[com.google.android.gms:style/PayButtonLightTheme, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]}
W/ResourcesCompat(32156): at android.content.res.TypedArray.getColor(TypedArray.java:529)
W/ResourcesCompat(32156): at m.jf.b(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (190800-0):18)
W/ResourcesCompat(32156): at m.jf.a(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (190800-0):24)
W/ResourcesCompat(32156): at m.jb.a(:com.google.android.gms.dynamite_dynamitemodulesc@[email protected] (190800-0):126)
W/ResourcesCompat(32156): at com.google.android.material.imageview.ShapeableImageView.