Flutter SDK Integration
Integration guide for the CICReader Flutter plugin, version 1.0.8. The entry point is CakeEidPlugin.
Build Specifications
| What | Description |
|---|---|
| iOS | Xcode 15.2+, target iOS 13+ |
| Android | Kotlin 1.7.10, minimum Android SDK 21 |
Integration
iOS
Enable the Near Field Communication Tag Reading capability, then update Info.plist:
<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
allprojects {
repositories {
maven { url "https://maven.google.com" }
maven { url "https://jcenter.bintray.com" } // make sure this is included
}
}Initialize
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:
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
baseUrl | string | Yes | — | Base URL for API calls. |
enableCheckData | bool | No | true | Verify NFC data against Cake RAR. |
readTimeoutMs | int | No | 60000 | API read timeout in milliseconds. |
writeTimeoutMs | int | No | 60000 | API write timeout in milliseconds. |
cacheScanStrategy | NfcCacheScanStrategy | No | NO_CACHE | See 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
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
}| Param | Type | Required | Default | Description |
|---|---|---|---|---|
idCard | string | Yes | — | The last 9 digits of the NID number. |
dob | string | Yes | — | Date of birth, format yyMMdd. |
expiryDate | string | Yes | — | Card expiry date, format yyMMdd. |
accessToken | string | Yes | — | Request access token. |
refId | string | Yes | — | Transaction reference ID to verify. |
Using CAN — 12-digit ID number
try {
final result = await eidPlugin.readCard(
idCard: idCard, // Full 12 digits of NID
accessToken: accessToken,
refId: refId,
);
} catch (e) {
// Error handling
}| Param | Type | Required | Default | Description |
|---|---|---|---|---|
idCard | string | Yes | — | The full 12-digit NID number. |
accessToken | string | Yes | — | Request access token. |
refId | string | Yes | — | 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
| Field | Type | Description |
|---|---|---|
com | string | Unicode version info and the list of available data groups. Base64. |
sod | string | The SOD data from the NFC scan. Base64. |
dg1 | string | Individual basic details — MRZ information. Base64. |
dg2 | string | Citizen facial image encoding. Base64. |
dg13 | string | Citizen-related information. Base64. |
dg14 | string | Used for the EAC access mechanism. Base64. |
dg15 | string | Public key, used for Passive Authentication. Base64. |
cloneStatus | NfcCloneStatus | Clone status of the card. See Mobile SDK Overview § Clone Status. |
Citizen fields — API derived
| Field | Type | Description |
|---|---|---|
citizenIdentify | string | Identification number of the citizen. |
oldCitizenIdentify | string | Old identification number. |
fullName | string | Full name. |
dateOfBirth | string | Date of birth. |
dateOfExpiry | string | Card expiry date. |
gender | string | Gender. |
nationality | string | Nationality. |
ethnicity | string | Ethnicity. |
religion | string | Religion. |
placeOfOrigin | string | Place of origin. |
placeOfResidence | string | Place of residence. |
personalIdentification | string | Personal identification characteristics. |
dateProvide | string | Date the card was issued. |
fatherName | string | Father's name. |
motherName | string | Mother's name. |
partnerName | string | Partner's name. |
faceImage | string | Facial image. Base64. |
isVerified | bool | Whether the card was verified by RAR. |
verificationKey | string | Verification key — pass this to Verify NFC. |
requestId | string | Request 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:
| Field | Type | Description |
|---|---|---|
UserCancelled | 3 | The user cancelled the operation. |
SessionOnGoing | 4 | Another reading session is in progress. |
Unspecified | -1 | An 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
| Field | Type | Description |
|---|---|---|
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
- Verify NFC — redeem the
verificationKeyfrom your backend - Error Codes — platform error tables
- Mobile SDK Overview — concepts shared across platforms