Flutter Example: How to handle asynchronous scan processing with callbacks

Summary
A code example in Flutter to utilize callbacks for asynchronous scan processing. This can be used for post-processing tasks like displaying UI elements and handling scan results.
  	 
 //Define variables
 var _isScanStarted = false.obs; // Using .obs
 get isScanStarted => this._isScanStarted.value; // Getter
 set isScanStarted(value) => this._isScanStarted.value = value; // Setter

//Initiate FaceScan and use then() to attach callback function to be called when scan is completed
   try {
   await platform.invokeMethod("startFaceScan", options).then((value) {
    print('[ DATA FOUND ========>>  ]');
    isScanStarted = false;
    btnController.stop();
    handleFaceScanResults(value);
   });
  } on PlatformException catch (error) {
   btnController.stop();

//Initiate BodyScan and use then() to attach callback function to be called when scan is completed
try {
   await platform.invokeMethod("startBodyScan", options).then((value) {
    print('[ DATA FOUND ========>>  ]');
    isScanStarted = false;
    btnController.stop();
    handleBodyScanResults(value);
   });
  } on PlatformException catch (error) {
  btnController.stop();
		
  
Copied!