mca_official_flutter_sdk 0.7.56-beta.13 mca_official_flutter_sdk: ^0.7.56-beta.13 copied to clipboard
The MyCover.ai SDK is a comprehensive Flutter plugin for buying insurance, supporting iOS and Android, with flexible payments, secure transactions, and a user-friendly interface.
The Official MyCover.ai SDK #
A Flutter plugin for buying insurance, supports both iOS and Android platforms .
Features #
Get your insurance and make payment
Getting started #
- Add package mca_official_flutter_sdk to your pubspec.yaml file
- Run flutter pub get
- Add required permission for the image pickers and camera
- Add required permission for the geolocation
- Add jcenter() to allprojects dependecy ( android -> build.gradle )
- Ensure that your "org.jetbrains.kotlin.android" is the latest version or not less than "2.0.0" ( android -> settings.gradle )
iOS Permissions #
Add the following keys to your Info.plist
file to request permission to use the camera and photo library:
<key>NSCameraUsageDescription</key>
<string>This app needs pictures for profile update</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs pictures for profile update</string>
Usage #
Some parameters are required whilst initialising the SDK, others are optional:
-
publicKey: (required) The public key from your distributor's dashboard. This is always required to initialize a purchase.
-
onComplete: (required) The callback function that is called after the SDK implementation is complete.
-
paymentOption: (optional) Required if using a wallet for payment. You must provide the payment reference number. Not required if the payment option defaults to the gateway.
-
debitWalletReference: (optional) Required for uncompleted purchases from the gateway or wallet initialization. Not needed for new/fresh purchases with the default (gateway) payment method.
-
transactionType: (optional) Indicates the intended action when using the SDK. The default is purchase.
-
productId: (optional) An array/list of product IDs. If only one product ID is provided, a purchase for that single product is initialized. If more than one or empty, all products are initialized, and you can select a product to purchase.
-
form: (optional) Basic information you would like to pass into the initialization.
Initialization #
- Initialize the SDK without any extra properties
import 'package:mca_official_flutter_sdk/mca_official_flutter_sdk.dart';
return Scaffold(
body: MyCoverAI(
context: context,
publicKey: "MCAPUBK_TEST|49303c8b-4fb4-4d8b-a4d3-c2f6f6d0fb62",
),
)
- Naviagate directly to the SDK
import 'package:mca_official_flutter_sdk/mca_official_flutter_sdk.dart';
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => MyCoverAI(
context: context,
walletReference: data,
paymentOption:
selectedPaymentOption,
)));
- Initialize the SDK with all extra properties
import 'package:mca_official_flutter_sdk/mca_official_flutter_sdk.dart';
void onComplete(SdkResponse response) {
PolicyModel purchasedPolicy = response.policyModel;
Navigator.of(response.context).pushReplacement(MaterialPageRoute(
builder: (context) => const PostSdkScreen(),
));
}
void onClose(dynamic result) {
Navigator.of(result['context']).pushReplacement(MaterialPageRoute(
builder: (context) => const PreSdkScreen(),
));
}
MyCoverAI(
publicKey: "MCAPUBK_TEST|49303c8b-4fb4-4d8b-a4d3-c2f6f6d0fb62",
form: const {
'email': "fuhad@mycovergenius.com",
'first_name': 'Fuhad',
'last_name': 'Aminu',
'phone': '08123232332',
},
onComplete: onComplete,
onClose: onClose,
context: context,
transactionType: TransactionType.purchase,
isContactFieldsEditable: false,
paymentOption: widget.paymentOption,
debitWalletReference: widget.walletReference,
productId: const [
"fab6bda1-b870-4648-8704-11c1802a51d0",
"c1d0f39c-0b8a-452f-a876-78bef8dde1d9",
"b83d5f4d-e868-4782-bb35-df6e3344ae7d",
],
),
Additional information #
Add the required permission for image picker on Android and iOS android manifest and info.plist respectively The app depends on image picker