TwkHelper class
Main helper class for interacting with the Tawakkalna SDK.
This class provides a unified interface to all Tawakkalna API methods, including both V1 and V2 APIs. It automatically selects the appropriate implementation based on the platform and build mode:
- Web + Release: Uses SDK implementation (real data when in Tawakkalna app)
- Non-Web + Debug: Uses mock implementation for testing
Example:
// Use default implementation (mock for debug, SDK for release)
final twk = TwkHelper();
// Or provide custom implementations
final twk = TwkHelper(
v1Api: MyCustomV1Impl(),
v2Api: MyCustomV2Impl(),
);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addDocument(
{required String documentName, required String documentContent, required String referenceNumber, required int categoryId}) → Future< void> - Adds a new document to the user's Tawakkalna document repository.
-
apiLog(
{required String url, required int methodType, String? requestBody, Map< String, String> ? requestHeaders, DateTime? requestDateTime, String? responseBody, Map<String, String> ? responseHeaders, DateTime? responseDateTime, required int responseCode}) → Future<void> - Logs API requests and responses for debugging and monitoring.
-
askCameraPermission(
) → Future< bool> - Requests camera access permission from the user.
-
askGalleryPermission(
) → Future< bool> - Requests gallery/photo library access permission from the user.
-
askPushNotificationPermission(
) → Future< bool> - Requests push notification permission from the user.
-
askUserLocationPermission(
) → Future< bool> - Requests user location permission (approximate).
-
askUserPreciseLocationPermission(
) → Future< bool> - Requests precise location permission from the user.
-
authenticateBiometric(
) → Future< bool> - Authenticates the user using biometric authentication (fingerprint/Face ID).
-
deleteDocument(
{required String referenceNumber, required int categoryId}) → Future< void> - Deletes a document from the user's Tawakkalna document repository.
-
generalLog(
{required String eventName, required LogType logType, required String logMessage}) → Future< void> - Logs general events and messages for debugging.
-
generateToken(
) → Future< String> - Generates an authentication token for API requests.
-
getCameraPhoto(
) → Future< TwkFile?> - Captures a photo using the device camera.
-
getCameraVideo(
) → Future< TwkFile?> - Captures a video using the device camera.
-
getDeviceInfo(
) → Future< DeviceInfo?> - Retrieves information about the user's device.
-
getFileBase64(
) → Future< String?> - Gets a file's content as a base64-encoded string.
-
getFileId(
) → Future< String?> - Gets a file identifier for a selected file.
-
getGalleryMulti(
) → Future< List< TwkFile> > - Allows the user to select multiple photos from their gallery.
-
getGalleryMultiVideo(
) → Future< List< TwkFile> > - Allows the user to select multiple videos from their gallery.
-
getGallerySingle(
) → Future< TwkFile?> - Allows the user to select a single photo from their gallery.
-
getGallerySingleVideo(
) → Future< TwkFile?> - Allows the user to select a single video from their gallery.
-
getImage(
String nationalId) → Future< Uint8List?> - Retrieves the profile image for a user by their national ID.
-
getRawData(
TwkFile file) → Future< Uint8List> - Gets the raw binary data from a TwkFile.
-
getUserBirthCity(
) → Future< BirthCity?> - Retrieves the user's birth city.
-
getUserBirthDate(
) → Future< DateTime?> - Retrieves the user's birth date.
-
getUserBloodType(
) → Future< BloodType?> - Retrieves the user's blood type.
-
getUserDegreeType(
) → Future< String?> - Retrieves the user's degree/education type.
-
getUserDisabilityType(
) → Future< DisabilityType?> - Retrieves the user's disability type if applicable.
-
getUserDocumentNumber(
) → Future< String?> - Retrieves the user's document number (national ID or Iqama number).
-
getUserEmail(
) → Future< String?> - Retrieves the user's email address.
-
getUserFamilyMembers(
{int? minAge, int? maxAge, Gender? gender}) → Future< List< FamilyMember> > - Retrieves the user's family members with optional filtering.
-
getUserFullName(
) → Future< FullName> - Retrieves the user's full name in both Arabic and English.
-
getUserGender(
) → Future< Gender?> - Retrieves the user's gender.
-
getUserHealthStatus(
) → Future< HealthStatus> - Retrieves the user's current health status.
-
getUserId(
) → Future< int> - Retrieves the user's unique ID in the Tawakkalna system.
-
getUserIdExpiryDate(
) → Future< DateTime?> - Retrieves the expiry date of the user's ID document.
-
getUserIqamaType(
) → Future< IqamaType> - Retrieves the user's Iqama (residence permit) type.
-
getUserLocation(
) → Future< Location?> - Retrieves the user's current location.
-
getUserMaritalStatus(
) → Future< MaritalStatus> - Retrieves the user's marital status.
-
getUserMobileNumber(
) → Future< String?> - Retrieves the user's mobile phone number.
-
getUserNationalAddress(
) → Future< List< NationalAddress> > - Retrieves the user's registered national addresses.
-
getUserNationality(
) → Future< NationalityEnity?> - Retrieves the user's nationality information.
-
getUserNationalityIso(
) → Future< String?> - Retrieves the user's nationality as an ISO country code.
-
getUserOccupation(
) → Future< String?> - Retrieves the user's occupation/profession.
-
getUserPaidViolations(
) → Future< List< Violation> > - Retrieves the user's paid traffic violations.
-
getUserPassports(
) → Future< PassportResponse> - Retrieves the user's passport information.
-
getUserProfilePhoto(
) → Future< String?> - Retrieves the user's profile photo.
-
getUserSponsors(
{int? minAge, int? maxAge, Gender? gender}) → Future< List< Sponsor> > - Retrieves the user's sponsors (kafeel) with optional filtering.
-
getUserType(
) → Future< UserType> - Retrieves the user's type (citizen, resident, or visitor).
-
getUserUnPaidViolations(
) → Future< List< Violation> > - Retrieves the user's unpaid traffic violations.
-
getUserVehicles(
) → Future< List< Vehicle> > - Retrieves all vehicles registered under the user's name.
-
livenessCheckCamera(
{List< Map< ? configurations}) → Future<String, dynamic> >Map< String, dynamic> ?> - Performs liveness detection using the device camera.
-
livenessCheckImageFromFiles(
{List< Map< ? configurations}) → Future<String, dynamic> >Map< String, dynamic> ?> - Performs liveness detection on images from files.
-
livenessCheckImageFromGallery(
{List< Map< ? configurations}) → Future<String, dynamic> >Map< String, dynamic> ?> - Performs liveness detection on images selected from the gallery.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openScreen(
{required String screenType, Map< String, dynamic> ? params}) → Future<void> - Opens a specific screen in the Tawakkalna app.
-
openService(
{required String serviceId, Map< String, dynamic> ? params}) → Future<void> - Opens another service within the Tawakkalna app.
-
openUrl(
{required String url, required UrlType urlType}) → Future< void> - Opens a URL in a browser (internal or external).
-
postCard(
{required String actionType, required Map< String, dynamic> payload}) → Future<void> - Posts a card/action to the Tawakkalna feed or notification system.
-
scanCode(
) → Future< String?> - Activates the QR/barcode scanner.
-
setPaymentConfiguration(
{required List< String> callbackSuccessUrlList, required List<String> callbackFailureUrlList, required String successPageName, required String failurePageName}) → Future<void> - Configures payment callback URLs and pages.
- Shares a file using the device's share functionality.
- Captures and shares a screenshot of the current screen.
-
startApiIntercept(
) → Future< void> - Starts intercepting API calls for debugging/logging.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateDocument(
{required String documentName, required String documentContent, required String referenceNumber, required int categoryId}) → Future< void> - Updates an existing document in the user's repository.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited