Add document scanner
This commit is contained in:
		
							
								
								
									
										39
									
								
								moneymgr_mobile/lib/routes/scan/scan_screen.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								moneymgr_mobile/lib/routes/scan/scan_screen.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
 | 
			
		||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
 | 
			
		||||
import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart';
 | 
			
		||||
 | 
			
		||||
part 'scan_screen.g.dart';
 | 
			
		||||
 | 
			
		||||
@riverpod
 | 
			
		||||
Future<String> _scanDocument(Ref ref) async {
 | 
			
		||||
  var configuration = DocumentScanningFlow(
 | 
			
		||||
    appearance: DocumentFlowAppearanceConfiguration(
 | 
			
		||||
      statusBarMode: StatusBarMode.DARK,
 | 
			
		||||
    ),
 | 
			
		||||
    cleanScanningSession: true,
 | 
			
		||||
    outputSettings: DocumentScannerOutputSettings(pagesScanLimit: 1),
 | 
			
		||||
    screens: DocumentScannerScreens(
 | 
			
		||||
      review: ReviewScreenConfiguration(enabled: false),
 | 
			
		||||
    ),
 | 
			
		||||
  );
 | 
			
		||||
  var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration);
 | 
			
		||||
  print("@@@");
 | 
			
		||||
  print(documentResult);
 | 
			
		||||
  print("####");
 | 
			
		||||
 | 
			
		||||
  return "changeme";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ScanScreen extends HookConsumerWidget {
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context, WidgetRef ref) {
 | 
			
		||||
    final boredSuggestion = ref.watch(_scanDocumentProvider);
 | 
			
		||||
    // Perform a switch-case on the result to handle loading/error states
 | 
			
		||||
    return switch (boredSuggestion) {
 | 
			
		||||
      AsyncData(:final value) => Text('data: $value'),
 | 
			
		||||
      AsyncError(:final error) => Text('error: $error'),
 | 
			
		||||
      _ => const Center(child: CircularProgressIndicator()),
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user