Skip to content

Commit

Permalink
202408 fixes (#1893)
Browse files Browse the repository at this point in the history
* chore: upgrade dependencies to 3.24 and fix analyzer issues

* fix  score violations

* fix dependencies

* fix #1886 and #1862 by adding missing params to payment element

* chore: move android example to new gradle plugin and flutter gradle structure

---------

Co-authored-by: Remon <[email protected]>
  • Loading branch information
remonh87 and Remon authored Aug 25, 2024
1 parent 8bd0e1b commit aa4e9a2
Show file tree
Hide file tree
Showing 59 changed files with 3,648 additions and 1,570 deletions.
16 changes: 7 additions & 9 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,9 +22,7 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


android {
namespace 'com.flutter.stripe.example'
Expand Down Expand Up @@ -65,7 +64,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.7.0'
implementation 'com.google.android.gms:play-services-wallet:19.1.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
13 changes: 0 additions & 13 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.8.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 13 19:26:48 WET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
30 changes: 22 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.5.1" apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
}

include ":app"
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ dependencies:
sdk: flutter
flutter_stripe: ^10.2.0
flutter_stripe_web: ^5.1.0
pay: ^1.1.0
pay: ^2.0.0
http: ^1.1.0
font_awesome_flutter: ^10.6.0
platform: ^3.0.0
web: ^0.5.1
web: ^1.0.0

dev_dependencies:
integration_test:
Expand Down
8 changes: 3 additions & 5 deletions packages/stripe/lib/src/widgets/apple_pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const double _kApplePayButtonDefaultHeight = 48;
class ApplePayButton extends StatelessWidget {
ApplePayButton({
Key? key,
super.key,
this.style = PlatformButtonStyle.automatic,
this.type = PlatformButtonType.plain,
this.cornerRadius = 4,
Expand All @@ -30,8 +30,7 @@ class ApplePayButton extends StatelessWidget {
constraints = (width != null || height != null)
? constraints?.tighten(width: width, height: height) ??
BoxConstraints.tightFor(width: width, height: height)
: constraints,
super(key: key);
: constraints;

/// Style of the the apple payment button.
///
Expand Down Expand Up @@ -113,7 +112,6 @@ class ApplePayButton extends StatelessWidget {

class _UiKitApplePayButton extends StatefulWidget {
const _UiKitApplePayButton({
Key? key,
required this.style,
required this.type,
this.cornerRadius = 4,
Expand All @@ -122,7 +120,7 @@ class _UiKitApplePayButton extends StatefulWidget {
this.onCouponCodeEntered,
this.onShippingMethodSelected,
this.onOrderTracking,
}) : super(key: key);
});

final PlatformButtonStyle style;
final PlatformButtonType type;
Expand Down
7 changes: 3 additions & 4 deletions packages/stripe/lib/src/widgets/aubecs_debit_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class AubecsFormField extends StatelessWidget {
this.style,
this.companyName,
this.controller,
Key? key,
}) : super(key: key);
super.key,
});

@override
Widget build(BuildContext context) {
Expand All @@ -36,8 +36,7 @@ class _AubecsFormField extends StatefulWidget {
this.style,
this.companyName,
this.controller,
Key? key,
}) : super(key: key);
});

@override
_AubecsFormFieldState createState() => _AubecsFormFieldState();
Expand Down
16 changes: 7 additions & 9 deletions packages/stripe/lib/src/widgets/card_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'keep_visible_on_focus.dart';
class CardField extends StatefulWidget {
const CardField({
this.onCardChanged,
Key? key,
super.key,
this.onFocus,
this.decoration,
this.enablePostalCode = false,
Expand All @@ -33,7 +33,7 @@ class CardField extends StatefulWidget {
this.preferredNetworks,
this.androidPlatformViewRenderType =
AndroidPlatformViewRenderType.expensiveAndroidView,
}) : super(key: key);
});

/// Decoration related to the input fields.
final InputDecoration? decoration;
Expand Down Expand Up @@ -282,7 +282,6 @@ class _MethodChannelCardField extends StatefulWidget {
this.onCardChanged,
required this.controller,
required this.androidPlatformViewRenderType,
Key? key,
this.onFocus,
this.style,
this.placeholder,
Expand All @@ -301,8 +300,7 @@ class _MethodChannelCardField extends StatefulWidget {
constraints = (width != null || height != null)
? constraints?.tighten(width: width, height: height) ??
BoxConstraints.tightFor(width: width, height: height)
: constraints,
super(key: key);
: constraints;

final BoxConstraints? constraints;
final CardFocusCallback? onFocus;
Expand Down Expand Up @@ -613,12 +611,12 @@ class _MethodChannelCardFieldState extends State<_MethodChannelCardField>

class _AndroidCardField extends StatelessWidget {
const _AndroidCardField({
Key? key,
required this.viewType,
required this.creationParams,
required this.onPlatformViewCreated,
required this.androidPlatformViewRenderType,
}) : super(key: key);
super.key,
});

final AndroidPlatformViewRenderType androidPlatformViewRenderType;
final String viewType;
Expand Down Expand Up @@ -673,11 +671,11 @@ class _AndroidCardField extends StatelessWidget {

class _UiKitCardField extends StatelessWidget {
const _UiKitCardField({
Key? key,
required this.viewType,
required this.creationParams,
required this.onPlatformViewCreated,
}) : super(key: key);
super.key,
});

final String viewType;
final Map<String, dynamic> creationParams;
Expand Down
16 changes: 7 additions & 9 deletions packages/stripe/lib/src/widgets/card_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'keep_visible_on_focus.dart';
class CardFormField extends StatefulWidget {
const CardFormField({
this.onCardChanged,
Key? key,
this.onFocus,
this.enablePostalCode = true,
this.countryCode,
Expand All @@ -31,7 +30,8 @@ class CardFormField extends StatefulWidget {
this.disabled = false,
this.controller,
this.preferredNetworks,
}) : super(key: key);
super.key,
});

/// Callback that will be executed when a specific field gets focus.
final CardFocusCallback? onFocus;
Expand Down Expand Up @@ -216,7 +216,6 @@ class _MethodChannelCardFormField extends StatefulWidget {
_MethodChannelCardFormField({
this.onCardChanged,
required this.controller,
Key? key,
this.onFocus,
this.style,
this.enablePostalCode = true,
Expand All @@ -234,8 +233,7 @@ class _MethodChannelCardFormField extends StatefulWidget {
constraints = (width != null || height != null)
? constraints?.tighten(width: width, height: height) ??
BoxConstraints.tightFor(width: width, height: height)
: constraints,
super(key: key);
: constraints;

final BoxConstraints? constraints;
final CardFocusCallback? onFocus;
Expand Down Expand Up @@ -526,11 +524,11 @@ class _MethodChannelCardFormFieldState

class _AndroidCardFormField extends StatelessWidget {
const _AndroidCardFormField({
Key? key,
required this.viewType,
required this.creationParams,
required this.onPlatformViewCreated,
}) : super(key: key);
super.key,
});

final String viewType;
final Map<String, dynamic> creationParams;
Expand Down Expand Up @@ -568,11 +566,11 @@ class _AndroidCardFormField extends StatelessWidget {

class _UiKitCardFormField extends StatelessWidget {
const _UiKitCardFormField({
Key? key,
required this.viewType,
required this.creationParams,
required this.onPlatformViewCreated,
}) : super(key: key);
super.key,
});

final String viewType;
final Map<String, dynamic> creationParams;
Expand Down
4 changes: 2 additions & 2 deletions packages/stripe/lib/src/widgets/google_pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class GooglePayButton extends StatefulWidget {
this.buttonType = PlatformButtonType.pay,
this.borderRadius,
this.appearance = PlatformButtonStyle.automatic,
Key? key,
}) : super(key: key);
super.key,
});

static const _viewType = 'flutter.stripe/google_pay_button';

Expand Down
4 changes: 2 additions & 2 deletions packages/stripe/lib/src/widgets/keep_visible_on_focus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'package:flutter/widgets.dart';

class KeepVisibleOnFocus extends StatefulWidget {
const KeepVisibleOnFocus({
Key? key,
required this.focusNode,
required this.child,
}) : super(key: key);
super.key,
});

final FocusNode focusNode;

Expand Down
2 changes: 1 addition & 1 deletion packages/stripe/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
flutter_lints: ^4.0.0
2 changes: 1 addition & 1 deletion packages/stripe_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.3
flutter_lints: ^4.0.0

flutter:
plugin:
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.3
flutter_lints: ^4.0.0

flutter:
plugin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ extension type JsElementsCreateOptions._(JSObject o) {
String? locale,
String? clientSecret,
JsElementAppearance? appearance,
String? customerSessionClientSecret,
String loader,
});

external JSArray<Font> fonts;
external String locale;
external String clientSecret;
external String customerSessionClientSecret;
external JsElementAppearance appearance;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/stripe_js/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
freezed_annotation: ^2.2.0
json_annotation: ^4.8.1
meta: ^1.0.0
web: ^0.5.1
web: ^1.0.0

dev_dependencies:
build_runner: ^2.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extension ElementWaitFor on web.Element {
String selectors, {
Duration timeout = const Duration(seconds: 2),
}) async {
web.console.log(this.innerHTML.toJS);
final element = this.querySelector(selectors);
if (element != null) {
return element;
Expand Down
Loading

0 comments on commit aa4e9a2

Please sign in to comment.