Skip to content

Flutter SDK Integration ​

Integration guide for the CICReader Flutter plugin, version 1.0.8. The entry point is CakeEidPlugin.

Build Specifications ​

WhatDescription
iOSXcode 15.2+, target iOS 13+
AndroidKotlin 1.7.10, minimum Android SDK 21

Integration ​

iOS ​

Enable the Near Field Communication Tag Reading capability, then update Info.plist:

xml
<key>NFCReaderUsageDescription</key>
<string>{Enter your NFC usage description here}</string>

<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>A0000002471001</string>
    <string>A0000002472001</string>
    <string>00000000000000</string>
</array>

Android ​

groovy
allprojects {
    repositories {
        maven { url "https://maven.google.com" }
        maven { url "https://jcenter.bintray.com" }  // make sure this is included
    }
}

Initialize ​

dart
final eidPlugin = CakeEidPlugin();

final config = CakeNfcConfig(
  baseUrl: "<BASE_URL>",
  enableCheckData: true,
  readTimeoutMs: 60000,
  writeTimeoutMs: 60000,
  cacheScanStrategy: NfcCacheScanStrategy.NO_CACHE,
);

final success = await eidPlugin.initialize(config);

if (success) {
  print('Initialization succeeded');
}

Parameters:

ParamTypeRequiredDefaultDescription
baseUrlstringYes—Base URL for API calls.
enableCheckDataboolNotrueVerify NFC data against Cake RAR.
readTimeoutMsintNo60000API read timeout in milliseconds.
writeTimeoutMsintNo60000API write timeout in milliseconds.
cacheScanStrategyNfcCacheScanStrategyNoNO_CACHESee Mobile SDK Overview § Cache on Server Errors.

INFO

The Flutter constructor parameter is enableCheckData — the same setting the Android and iOS SDKs call enableCheckNfcData. Contact the CAKE team if initialization rejects the key.

Read the Chip ​

Using MRZ — 9-digit ID, date of birth, expiry date ​

dart
try {
  final result = await eidPlugin.readCIC(
    idCard: idCard,      // Last 9 digits of NID
    dob: dob,
    expiryDate: expiryDate,
    accessToken: accessToken,
    refId: refId,
  );
} catch (e) {
  // Error handling
}
ParamTypeRequiredDefaultDescription
idCardstringYes—The last 9 digits of the NID number.
dobstringYes—Date of birth, format yyMMdd.
expiryDatestringYes—Card expiry date, format yyMMdd.
accessTokenstringYes—Request access token.
refIdstringYes—Transaction reference ID to verify.

Using CAN — 12-digit ID number ​

dart
try {
  final result = await eidPlugin.readCard(
    idCard: idCard,      // Full 12 digits of NID
    accessToken: accessToken,
    refId: refId,
  );
} catch (e) {
  // Error handling
}
ParamTypeRequiredDefaultDescription
idCardstringYes—The full 12-digit NID number.
accessTokenstringYes—Request access token.
refIdstringYes—Transaction reference ID to verify.

Note the two methods have different names — readCIC for MRZ, readCard for CAN.

Result ​

CICCardResult carries the raw data groups plus, when enableCheckData is true, the parsed citizen fields.

Chip data ​

FieldTypeDescription
comstringUnicode version info and the list of available data groups. Base64.
sodstringThe SOD data from the NFC scan. Base64.
dg1stringIndividual basic details — MRZ information. Base64.
dg2stringCitizen facial image encoding. Base64.
dg13stringCitizen-related information. Base64.
dg14stringUsed for the EAC access mechanism. Base64.
dg15stringPublic key, used for Passive Authentication. Base64.
cloneStatusNfcCloneStatusClone status of the card. See Mobile SDK Overview § Clone Status.

Citizen fields — API derived ​

FieldTypeDescription
citizenIdentifystringIdentification number of the citizen.
oldCitizenIdentifystringOld identification number.
fullNamestringFull name.
dateOfBirthstringDate of birth.
dateOfExpirystringCard expiry date.
genderstringGender.
nationalitystringNationality.
ethnicitystringEthnicity.
religionstringReligion.
placeOfOriginstringPlace of origin.
placeOfResidencestringPlace of residence.
personalIdentificationstringPersonal identification characteristics.
dateProvidestringDate the card was issued.
fatherNamestringFather's name.
motherNamestringMother's name.
partnerNamestringPartner's name.
faceImagestringFacial image. Base64.
isVerifiedboolWhether the card was verified by RAR.
verificationKeystringVerification key — pass this to Verify NFC.
requestIdstringRequest ID of the authentication.

These names match the API field names, unlike the Android and iOS SDKs which use idCardNo / residenceAddress.

Error Handling ​

Three errors are common to both platforms:

FieldTypeDescription
UserCancelled3The user cancelled the operation.
SessionOnGoing4Another reading session is in progress.
Unspecified-1An unexpected error. The message carries the detail.

Beyond those, errors surface with the underlying platform's code — the iOS table for iOS builds, the Android table for Android builds. Both are in Error Codes.

Built-in Functions ​

FieldTypeDescription
isNfcAvailable()Future<bool>Whether NFC reading is available on the device.
isNfcEnable()Future<bool>Whether NFC is switched on. Android only — always true on iOS.
openNfcSetting()Future<void>Opens the device NFC settings screen. Android only.

Verifying the IPA Configuration ​

The same iOS production checklist applies — see iOS SDK Integration § Verifying the IPA Configuration.

Next Steps ​

Developers