Skip to content

Commit 141ddc9

Browse files
lreardonjonasbark
andauthored
Prefer initSurfaceAndroidView instead of initExpensiveAndroidView (#2258)
* Change to initSurfaceAndroidView for platform view * Change to initSurfaceAndroidView for Google Pay button * Change to initSurfaceAndroidView for platform view * Change to use initSurfaceAndroidView for platform view * Change default Android platform view render type to surfaceAndroidView --------- Co-authored-by: jonasbark <jonas.bark@gmx.de>
1 parent 8223938 commit 141ddc9

File tree

5 files changed

+42
-28
lines changed

5 files changed

+42
-28
lines changed

packages/stripe/lib/src/widgets/adress_sheet.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ class _AddressSheetState extends State<_AddressSheet> {
109109
},
110110
onCreatePlatformView: (params) {
111111
onPlatformViewCreated(params.id);
112-
return PlatformViewsService.initExpensiveAndroidView(
113-
id: params.id,
114-
viewType: _viewType,
115-
layoutDirection: TextDirection.ltr,
116-
creationParams: widget.addressSheetParams.toJson(),
117-
creationParamsCodec: const StandardMessageCodec(),
118-
)
112+
return PlatformViewsService.initSurfaceAndroidView(
113+
id: params.id,
114+
viewType: _viewType,
115+
layoutDirection: TextDirection.ltr,
116+
creationParams: widget.addressSheetParams.toJson(),
117+
creationParamsCodec: const StandardMessageCodec(),
118+
)
119119
..addOnPlatformViewCreatedListener(
120120
params.onPlatformViewCreated,
121121
)

packages/stripe/lib/src/widgets/aubecs_debit_form.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ class _AubecsFormFieldState extends State<_AubecsFormField> {
139139
},
140140
onCreatePlatformView: (params) {
141141
onPlatformViewCreated(params.id);
142-
return PlatformViewsService.initExpensiveAndroidView(
143-
id: params.id,
144-
viewType: _viewType,
145-
layoutDirection: TextDirection.ltr,
146-
creationParams: creationParams,
147-
creationParamsCodec: const StandardMessageCodec(),
148-
)
142+
return PlatformViewsService.initSurfaceAndroidView(
143+
id: params.id,
144+
viewType: _viewType,
145+
layoutDirection: TextDirection.ltr,
146+
creationParams: creationParams,
147+
creationParamsCodec: const StandardMessageCodec(),
148+
)
149149
..addOnPlatformViewCreatedListener(
150150
params.onPlatformViewCreated,
151151
)

packages/stripe/lib/src/widgets/card_field.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CardField extends StatefulWidget {
3333
this.preferredNetworks,
3434
this.onBehalfOf,
3535
this.androidPlatformViewRenderType =
36-
AndroidPlatformViewRenderType.expensiveAndroidView,
36+
AndroidPlatformViewRenderType.surfaceAndroidView,
3737
});
3838

3939
/// Decoration related to the input fields.
@@ -116,7 +116,7 @@ class CardField extends StatefulWidget {
116116
/// Type of platformview used for rendering on Android.
117117
///
118118
/// This is an advanced option and changing this should be tested on multiple android devices.
119-
/// Defaults to [AndroidPlatformViewRenderType.expensiveAndroidView]
119+
/// Defaults to [AndroidPlatformViewRenderType.surfaceAndroidView]
120120
final AndroidPlatformViewRenderType androidPlatformViewRenderType;
121121

122122
@override
@@ -681,6 +681,19 @@ class _AndroidCardField extends StatelessWidget {
681681
)
682682
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
683683
..create();
684+
case AndroidPlatformViewRenderType.surfaceAndroidView:
685+
return PlatformViewsService.initSurfaceAndroidView(
686+
id: params.id,
687+
viewType: viewType,
688+
layoutDirection: Directionality.of(context),
689+
creationParams: creationParams,
690+
creationParamsCodec: const StandardMessageCodec(),
691+
onFocus: () {
692+
params.onFocusChanged(true);
693+
},
694+
)
695+
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
696+
..create();
684697
case AndroidPlatformViewRenderType.androidView:
685698
return PlatformViewsService.initAndroidView(
686699
id: params.id,
@@ -731,7 +744,8 @@ const kCardFieldDefaultFontFamily = 'Roboto';
731744
enum AndroidPlatformViewRenderType {
732745
/// Controls an Android view that is composed using the Android view hierarchy
733746
expensiveAndroidView,
734-
747+
/// Like expensiveAndroidView, but Uses Texture Layer Hybrid Composition (TLHC) when possible, falling back to Hybrid Composition only when necessary.
748+
surfaceAndroidView,
735749
/// Use an Android view composed using a GL texture.
736750
///
737751
/// This is more efficient but has more issues on older Android devices.

packages/stripe/lib/src/widgets/card_form_field.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,16 @@ class _AndroidCardFormField extends StatelessWidget {
566566
),
567567
onCreatePlatformView: (params) {
568568
onPlatformViewCreated(params.id);
569-
return PlatformViewsService.initExpensiveAndroidView(
570-
id: params.id,
571-
viewType: viewType,
572-
layoutDirection: Directionality.of(context),
573-
creationParams: creationParams,
574-
creationParamsCodec: const StandardMessageCodec(),
575-
onFocus: () {
576-
params.onFocusChanged(true);
577-
},
578-
)
569+
return PlatformViewsService.initSurfaceAndroidView(
570+
id: params.id,
571+
viewType: viewType,
572+
layoutDirection: Directionality.of(context),
573+
creationParams: creationParams,
574+
creationParamsCodec: const StandardMessageCodec(),
575+
onFocus: () {
576+
params.onFocusChanged(true);
577+
},
578+
)
579579
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
580580
..create();
581581
},

packages/stripe/lib/src/widgets/google_pay_button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _GooglePayButtonState extends State<GooglePayButton> {
6666
},
6767
onCreatePlatformView: (params) {
6868
onPlatformViewCreated(params.id);
69-
return PlatformViewsService.initExpensiveAndroidView(
69+
return PlatformViewsService.initSurfaceAndroidView(
7070
id: params.id,
7171
viewType: GooglePayButton._viewType,
7272
layoutDirection: TextDirection.ltr,

0 commit comments

Comments
 (0)