diff --git a/example/lib/screens/address_sheet/address_sheet.dart b/example/lib/screens/address_sheet/address_sheet.dart index a8c6854d..e5197670 100644 --- a/example/lib/screens/address_sheet/address_sheet.dart +++ b/example/lib/screens/address_sheet/address_sheet.dart @@ -5,7 +5,7 @@ import 'package:stripe_example/widgets/example_scaffold.dart'; import 'package:stripe_example/widgets/response_card.dart'; class AddressSheetExample extends StatefulWidget { - const AddressSheetExample({Key? key}) : super(key: key); + const AddressSheetExample({super.key}); @override State createState() => _AddressSheetExampleState(); diff --git a/packages/stripe/lib/flutter_stripe.dart b/packages/stripe/lib/flutter_stripe.dart index 62c348db..98acdb68 100644 --- a/packages/stripe/lib/flutter_stripe.dart +++ b/packages/stripe/lib/flutter_stripe.dart @@ -2,7 +2,7 @@ export 'package:stripe_platform_interface/stripe_platform_interface.dart'; export 'src/model/apple_pay_button.dart'; export 'src/stripe.dart'; -export 'src/widgets/adresssheet.dart'; +export 'src/widgets/adress_sheet.dart'; // export 'src/widgets/apple_pay_button.dart'; export 'src/widgets/aubecs_debit_form.dart'; export 'src/widgets/card_field.dart'; diff --git a/packages/stripe/lib/src/widgets/adresssheet.dart b/packages/stripe/lib/src/widgets/adress_sheet.dart similarity index 60% rename from packages/stripe/lib/src/widgets/adresssheet.dart rename to packages/stripe/lib/src/widgets/adress_sheet.dart index 932f194e..577d5e02 100644 --- a/packages/stripe/lib/src/widgets/adresssheet.dart +++ b/packages/stripe/lib/src/widgets/adress_sheet.dart @@ -10,13 +10,9 @@ class AddressSheet extends StatelessWidget { required this.onSubmit, required this.onError, required this.params, - this.height = 300, super.key, }); - /// The height of the address sheet - final int height; - /// Called when the user submits their information final OnAddressSheetSubmit onSubmit; @@ -32,7 +28,6 @@ class AddressSheet extends StatelessWidget { onSubmit: onSubmit, onError: onError, addressSheetParams: params, - height: height, ); } } @@ -41,14 +36,12 @@ class _AddressSheet extends StatefulWidget { const _AddressSheet({ required this.onSubmit, required this.onError, - required this.height, required this.addressSheetParams, }); final AddressSheetParams addressSheetParams; final OnAddressSheetSubmit onSubmit; final OnAddressSheetError onError; - final int height; @override State<_AddressSheet> createState() => _AddressSheetState(); @@ -84,39 +77,35 @@ class _AddressSheetState extends State<_AddressSheet> { @override Widget build(BuildContext context) { - return SizedBox( - height: widget.height.toDouble(), - child: defaultTargetPlatform == TargetPlatform.iOS - ? UiKitView( - viewType: _viewType, - creationParamsCodec: const StandardMessageCodec(), - creationParams: widget.addressSheetParams.toJson(), - onPlatformViewCreated: onPlatformViewCreated, - ) - : PlatformViewLink( - surfaceFactory: (context, controller) { - return AndroidViewSurface( - controller: controller as AndroidViewController, - hitTestBehavior: PlatformViewHitTestBehavior.opaque, - gestureRecognizers: const >{}, - ); - }, - onCreatePlatformView: (params) { - onPlatformViewCreated(params.id); - return PlatformViewsService.initExpensiveAndroidView( - id: params.id, - viewType: _viewType, - layoutDirection: TextDirection.ltr, - creationParams: widget.addressSheetParams.toJson(), - creationParamsCodec: const StandardMessageCodec(), - ) - ..addOnPlatformViewCreatedListener( - params.onPlatformViewCreated) - ..create(); - }, - viewType: _viewType, - ), - ); + return defaultTargetPlatform == TargetPlatform.iOS + ? UiKitView( + viewType: _viewType, + creationParamsCodec: const StandardMessageCodec(), + creationParams: widget.addressSheetParams.toJson(), + onPlatformViewCreated: onPlatformViewCreated, + ) + : PlatformViewLink( + surfaceFactory: (context, controller) { + return AndroidViewSurface( + controller: controller as AndroidViewController, + hitTestBehavior: PlatformViewHitTestBehavior.opaque, + gestureRecognizers: const >{}, + ); + }, + onCreatePlatformView: (params) { + onPlatformViewCreated(params.id); + return PlatformViewsService.initExpensiveAndroidView( + id: params.id, + viewType: _viewType, + layoutDirection: TextDirection.ltr, + creationParams: widget.addressSheetParams.toJson(), + creationParamsCodec: const StandardMessageCodec(), + ) + ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) + ..create(); + }, + viewType: _viewType, + ); } } diff --git a/packages/stripe_ios/ios/Classes/AddressSheetFactory.swift b/packages/stripe_ios/ios/Classes/AddressSheetFactory.swift index f6e8afd8..fa4f299c 100644 --- a/packages/stripe_ios/ios/Classes/AddressSheetFactory.swift +++ b/packages/stripe_ios/ios/Classes/AddressSheetFactory.swift @@ -65,10 +65,14 @@ class AddressSheetPlatformView: NSObject, FlutterPlatformView { public func onCompleteAction(addressData: Dictionary?) { channel.invokeMethod("onSubmitAction", arguments: addressData) + formView.visible=false + formView.didSetProps(["visible"]) } public func onCancelAction(errorData: Dictionary?) { channel.invokeMethod("onErrorAction", arguments: errorData) + formView.visible=false + formView.didSetProps(["visible"]) } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {