Implementation rough notes
The thought process is to keep the complete business logic in Flutter (Dart files),
only for the below functions, we should reach to platform-specific code:
Data fetch from & store to DB (we have to live with this until the August release),
crypto functions - enc, dec, trust validations
SDK calls for bio matches/dedupe
Creating Registration packet
State management with providers
Separating platform-specific code with conditional imports (During the build process, Flutter analyzes the conditional imports and includes only the necessary platform-specific files based on the current platform. The platform-specific files are then compiled into the final app bundle)
screens(Only UI) ---------------- providers(state-mgmt & Business-logic) -----------may or may not--------- platform-specific code
Project structure:
project/
lib/
providers/
auth_provider.dart
models/
user_detail.dart
screens/
home
dashboard.dart
settings.dart
home.dart
onboard
onboard.dart
onboard_landing.dart
registration
language_selection.dart
registration.dart
registration_listing.dart
preview.dart
acknowledgment.dart
auth
pwd_auth.dart
finger_auth.dart
iris_auth.dart
face_auth.dart
widgets/
checkbox.dart
radio_button.dart
textbox.dart
dropdown.dart
utils/
constants.dart
file_storage.dart
validators/
regex.dart
mvel.dart
platform_spi/
auth_service.dart
user_service.dart
registration_service.dart
platform_android/
auth_service_impl.dart
user_service_impl.dart
registration_service_impl.dart
platform_web/
auth_service_impl.dart
user_service_impl.dart
registration_service_impl.dart
main.dart
For each scenario, here we are listing down the possible method channel calls to platform-specific code with the expected response DTO structure.
View(TODO) ---------- channels ------------- Pigeon ------------------ Platform specific code
SCENE:on_launch
1. ------------------------ getCenterMachineDetails() ------------------->
ResponseWrapper ->
{
response : {
centerName
centerId
centerStatus
machineName
machineId
machineStatus
},
errorCode : ""
}
"NOT_INITIALIZED"
//DO machine status check
//DO center status check
2. ------------------------ getGlobalParams() ------------------->
load all the global params (key-value pairs) in the context.
SCENE:Login user_validation -------------------getUserDetail(userId)------------------------------->
ResponseWrapper ->
{
response : {
userId
is_active
is_locked
is_onboarded
centerName
centerId
machineName
machineId
failedAttempts
authMethods: []
},
errorCode : ""
}
//DO user validation
online: ---------------------------------------- auth endpoint call -----------------------------> enc(response)
<---------------------------------------------------------------------------------- decrypted(response)
//validate auth token (signature check & expiry & aud & iss check)
//parse token ----------------------------- saveUserDetail(userId)
{
username
password(plain)
roles
auth-token
refresh-token
}
offline:
credential_check ------------(offline) getStoredCredential(userId, authMethod)------------------->
ResponseWrapper ->
{
response : [{
credential : <string>
salt: <string>
type: <string>
subType: <string>
}],
errorCode : ""
}
//Do pwd comparision
//store user logged in details in
SharedPreferences
NAVIGATION:Load onboard page only if valid user session details found in sharedPreferences & is_onboarded is false
NAVIGATION:Load homepage only if valid user session details found in sharedPreferences
SCENE:Sync
only when ONLINE and valid auth-token session (either OPERATOR/SUPERVISOR):
policy_certificate_sync ------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
configuration_sync ------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
schema_sync ------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
masterdata_sync------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
userdetails_sync------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
trust_certs_sync------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
prereg_data_sync------------------------------------------------------------------ API call
store in DB
<----------------------------------------------- ResponseWrapper { response: <status>, errorCode: "" }
//Handle progress & errors
offline: Machine is offline
//DO nothing
SCENE:Registration
// TODO