### Implement Start Method Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/start.html This is a placeholder implementation for the start method. It should be replaced with actual scanner initialization logic. ```dart Future start(StartOptions startOptions) { throw UnimplementedError('start() has not been implemented.'); } ``` -------------------------------- ### start Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform-class.html Starts the barcode scanner and prepares a scanner view with the specified options. ```APIDOC ## start ### Description Start the barcode scanner and prepare a scanner view. ### Method `Future start(StartOptions startOptions)` ### Parameters * **startOptions** (StartOptions) - Required - Options to configure the scanner startup. ``` -------------------------------- ### start method Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/start.html Starts the barcode scanner and prepares a scanner view. This method will request camera permissions and uses the provided StartOptions.cameraDirection to configure the camera. ```APIDOC ## start method ### Description Starts the barcode scanner and prepares a scanner view. Upon calling this method, the necessary camera permission will be requested. The given StartOptions.cameraDirection is used as the direction for the camera that needs to be set up. ### Signature ```dart Future start(StartOptions startOptions) ``` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **startOptions** (StartOptions) - Required - Options to configure the scanner startup, including camera direction. ``` -------------------------------- ### start Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController-class.html Starts the barcode scanning process. ```APIDOC ## start({CameraFacing? cameraDirection, CameraLensType? cameraLensType}) ### Description Start scanning for barcodes. ### Method Future ### Parameters #### Query Parameters - **cameraDirection** (CameraFacing?) - Optional - The camera direction to use. - **cameraLensType** (CameraLensType?) - Optional - The lens type to use. ``` -------------------------------- ### Get Supported Lenses Example Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/getSupportedLenses.html Call this method before starting the scanner to check available camera lenses. It prints the available lenses or a message if none are found. ```dart final supportedLenses = await controller.getSupportedLenses(); if (supportedLenses.isEmpty) { print('No camera lenses available'); } else { print('Available lenses: $supportedLenses'); } ``` -------------------------------- ### start Method Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/start.html Starts the barcode scanning process. This method can be configured with camera direction and lens type. It handles permission requests and ensures the camera is not already running. ```APIDOC ## start Method ### Description Starts scanning for barcodes. Allows specifying camera direction and lens type. Requests camera permissions if not already granted. Does nothing if the camera is already running. ### Method Signature ```dart Future start({ CameraFacing? cameraDirection, CameraLensType? cameraLensType, }) ``` ### Parameters - **cameraDirection** (CameraFacing?, optional) - Specifies the camera to use (e.g., front or back). Defaults to the current facing value if null. - **cameraLensType** (CameraLensType?, optional) - Specifies the camera lens type. Defaults to the current lens type if null. ### Behavior - Requests necessary camera permissions. - If permission is denied on iOS, macOS, or Web, it cannot be re-requested. - Does nothing if the camera is already running. - Throws `MobileScannerException` if the controller is disposed or not attached. - Throws `MobileScannerException` if `cameraDirection` is `CameraFacing.unknown`. - Throws `MobileScannerException` if the controller is already initializing. ``` -------------------------------- ### StartOptions Properties Source: https://pub.dev/documentation/gscankit/latest/gscankit/StartOptions-class.html Exposes properties for configuring and inspecting the scanner's start options. ```APIDOC ## StartOptions Properties ### autoZoom → bool Whether the camera should auto zoom if the detected code is to far from the camera. ### cameraDirection → CameraFacing The direction for the camera. ### cameraLensType → CameraLensType The preferred lens type for the camera. ### cameraResolution → Size? The desired camera resolution for the scanner. ### detectionSpeed → DetectionSpeed The detection speed for the scanner. ### detectionTimeoutMs → int The detection timeout for the scanner, in milliseconds. ### formats → List The barcode formats to detect. ### hashCode → int The hash code for this object. ### initialZoom → double? The initial zoom scale factor for the camera. ### invertImage → bool Invert image colors for analyzer to support white-on-black barcodes, which are not supported by MLKit. ### returnImage → bool Whether the detected barcodes should provide their image data. ### runtimeType → Type A representation of the runtime type of the object. ### torchEnabled → bool Whether the torch should be turned on when the scanner starts. ``` -------------------------------- ### Start Scanner After Widget is Mounted Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerErrorCode.html Shows an alternative correct approach to starting the MobileScannerController. It ensures the controller is started after the widget has been mounted and the MobileScanner is available in the widget tree, preventing controllerNotAttached errors. ```dart class ScannerExample extends StatefulWidget { const ScannerExample({super.key}); @override State createState() => _ScannerExampleState(); } class _ScannerExampleState extends State { final MobileScannerController controller = MobileScannerController(); bool _showScanner = false; void start() { if (_showScanner) return; setState(() { _showScanner = true; }); // The MobileScanner will be in the widget tree in the next frame. controller.start(); } @override Widget build(BuildContext context) { return Column( children: [ ElevatedButton(onPressed: start, child: const Text('Button')), if (_showScanner) Expanded(child: MobileScanner(controller: controller)), ], ); } } ``` -------------------------------- ### GScanKit Configuration Example Source: https://pub.dev/packages/gscankit Configure GScanKit with various options including controller, detection callbacks, and detailed overlay styling. Use this to customize the scanner's appearance and functionality. ```dart GscanKit( controller: controller, // MobileScannerController instance onDetect: (BarcodeCapture capture) { // Handle scanned result }, floatingOption: [], // Add custom floating widgets if needed gscanOverlayConfig: GscanOverlayConfig( scannerScanArea: ScannerScanArea.center, // Focus scan area in center scannerBorder: ScannerBorder.visible, // Enable visible border scannerBorderPulseEffect: ScannerBorderPulseEffect.enabled, // Apple-style border pulse borderColor: Colors.white, // Customize border color borderRadius: 24.0, // Rounded border edges scannerLineAnimationColor: Colors.green, // Scanning line color scannerOverlayBackground: ScannerOverlayBackground.blur, // Blurred camera overlay scannerLineAnimation: ScannerLineAnimation.enabled, // Enable line animation ), ) ``` -------------------------------- ### Correctly Start Scanner with Attached Widget Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerErrorCode.html Provides a correct implementation for starting the MobileScannerController by ensuring the MobileScanner widget is present in the widget tree before calling controller.start(). This avoids the controllerNotAttached error. ```dart class ScannerExample extends StatefulWidget { const ScannerExample({super.key}); @override State createState() => _ScannerExampleState(); } class _ScannerExampleState extends State { final MobileScannerController controller = MobileScannerController(); @override Widget build(BuildContext context) { return Column( children: [ ElevatedButton( // The MobileScanner is already in the widget tree. onPressed: controller.start, child: const Text('Button'), ), Expanded(child: MobileScanner(controller: controller)), ], ); } } ``` -------------------------------- ### Example createState Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScanner/createState.html Subclasses should override this method to return a newly created instance of their associated State subclass. The framework may call this method multiple times. ```dart @override State createState() => _SomeWidgetState(); ``` ```dart @override State createState() => _MobileScannerState(); ``` -------------------------------- ### isStarting Property Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerState/isStarting.html A boolean value indicating if the mobile scanner is currently starting. This helps prevent multiple calls to the start method. ```APIDOC ## isStarting Property ### Description Indicates whether the mobile scanner is currently in the process of starting. This flag helps prevent duplicate calls to MobileScannerController.start. ### Type bool ### Implementation ```dart final bool isStarting; ``` ``` -------------------------------- ### torchEnabled Property Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/torchEnabled.html Controls whether the flashlight should be turned on when the camera is started. Defaults to false. ```APIDOC ## torchEnabled Property ### Description Whether the flashlight should be turned on when the camera is started. ### Type `bool` ### Default Value `false` ### Implementation ```dart final bool torchEnabled; ``` ``` -------------------------------- ### CalendarEvent Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/CalendarEvent/CalendarEvent.html Creates a new CalendarEvent instance with optional parameters for description, start and end times, location, organizer, status, and summary. ```APIDOC ## CalendarEvent Constructor ### Description Create a new CalendarEvent instance. ### Parameters #### Constructor Parameters - **description** (String?) - Optional - Description of the event. - **start** (DateTime?) - Optional - The start date and time of the event. - **end** (DateTime?) - Optional - The end date and time of the event. - **location** (String?) - Optional - The location of the event. - **organizer** (String?) - Optional - The organizer of the event. - **status** (String?) - Optional - The status of the event. - **summary** (String?) - Optional - A summary of the event. ``` -------------------------------- ### Example Usage of scaleCorners Source: https://pub.dev/documentation/gscankit/latest/gscankit/Barcode/scaleCorners.html Demonstrates how to use the scaleCorners method to convert barcode corner offsets to a target widget's size. Ensure you have the BuildContext to access the target widget's size. ```dart final BuildContext context; final Barcode barcode = Barcode( size: Size(60, 60), corners: [ Offset(10, 10), Offset(50, 10), Offset(50, 50), Offset(10, 50), ], ); final List scaledCorners = barcode.scaleCorners( context.size ?? Size.zero ); ``` -------------------------------- ### Start Barcode Scanning Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/start.html Initiates barcode scanning. This method requests camera permissions and configures scanning options. It does nothing if the camera is already running and throws an error if the controller is disposed or initializing. ```dart Future start({ CameraFacing? cameraDirection, CameraLensType? cameraLensType, }) async { if (_isDisposed) { throw MobileScannerException( errorCode: MobileScannerErrorCode.controllerDisposed, errorDetails: MobileScannerErrorDetails( message: MobileScannerErrorCode.controllerDisposed.message, ), ); } // If start was called before the MobileScanner widget // had a chance to call its initState method, // wait for it to be called, using a timeout. if (!_isAttachedCompleter.isCompleted) { // The timeout is currently an arbitrary value, // which should be long enough for the next frame // to propagate any pending changes to the widget tree. await _isAttachedCompleter.future .timeout(const Duration(milliseconds: 500)) .catchError((Object error, StackTrace stackTrace) { throw MobileScannerException( errorCode: MobileScannerErrorCode.controllerNotAttached, errorDetails: MobileScannerErrorDetails( message: MobileScannerErrorCode.controllerNotAttached.message, details: stackTrace.toString(), ), ); }); // Abort if the controller was disposed // while waiting for the widget to be attached. if (_isDisposed) { throw MobileScannerException( errorCode: MobileScannerErrorCode.controllerDisposed, errorDetails: MobileScannerErrorDetails( message: MobileScannerErrorCode.controllerDisposed.message, ), ); } } if (cameraDirection == CameraFacing.unknown) { throw const MobileScannerException( errorCode: MobileScannerErrorCode.genericError, errorDetails: MobileScannerErrorDetails( message: 'CameraFacing.unknown is not a valid camera direction.', ), ); } // Do nothing if the camera is already running. if (value.isRunning) { return; } if (value.isStarting) { throw MobileScannerException( errorCode: MobileScannerErrorCode.controllerInitializing, errorDetails: MobileScannerErrorDetails( message: MobileScannerErrorCode.controllerInitializing.message, ), ); } if (!_isDisposed) { value = value.copyWith(isStarting: true); } final options = StartOptions( cameraDirection: cameraDirection ?? facing, cameraLensType: cameraLensType ?? lensType, cameraResolution: cameraResolution, detectionSpeed: detectionSpeed, detectionTimeoutMs: detectionTimeoutMs, formats: formats, returnImage: returnImage, torchEnabled: torchEnabled, invertImage: invertImage, autoZoom: autoZoom, initialZoom: initialZoom, ); try { _setupListeners(); final viewAttributes = await MobileScannerPlatform.instance.start( options, ); if (!_isDisposed) { value = value.copyWith( availableCameras: viewAttributes.numberOfCameras, cameraDirection: viewAttributes.cameraDirection, cameraLensType: options.cameraLensType, isInitialized: true, isStarting: false, isRunning: true, size: viewAttributes.size, deviceOrientation: viewAttributes.initialDeviceOrientation, // Provide the current torch state. // Updates are provided by the `torchStateStream`. torchState: viewAttributes.currentTorchMode, ); } } on MobileScannerException catch (error) { // The initialization finished with an error. // To avoid stale values, reset the camera direction, // output size, torch state and zoom scale to the defaults. if (!_isDisposed) { value = value.copyWith( cameraDirection: CameraFacing.unknown, isInitialized: true, isStarting: false, isRunning: false, error: error, size: Size.zero, torchState: TorchState.unavailable, zoomScale: 1, ); } } } ``` -------------------------------- ### Add GScanKit Dependency Source: https://pub.dev/documentation/gscankit/latest/index.html Add the gscankit package to your pubspec.yaml file and run flutter pub get to install it. ```yaml dependencies: gscankit: ^latest_version # Replace with the latest version ``` -------------------------------- ### StartOptions Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/StartOptions-class.html Constructs a new StartOptions instance with specified camera and detection parameters. ```APIDOC ## StartOptions Constructor ### Description Constructs a new StartOptions instance. ### Parameters - **cameraDirection** (CameraFacing) - Required - The direction for the camera. - **cameraLensType** (CameraLensType) - Required - The preferred lens type for the camera. - **cameraResolution** (Size?) - Optional - The desired camera resolution for the scanner. - **detectionSpeed** (DetectionSpeed) - Required - The detection speed for the scanner. - **detectionTimeoutMs** (int) - Required - The detection timeout for the scanner, in milliseconds. - **formats** (List) - Required - The barcode formats to detect. - **returnImage** (bool) - Required - Whether the detected barcodes should provide their image data. - **torchEnabled** (bool) - Required - Whether the torch should be turned on when the scanner starts. - **invertImage** (bool) - Required - Invert image colors for analyzer to support white-on-black barcodes. - **autoZoom** (bool) - Required - Whether the camera should auto zoom if the detected code is too far from the camera. - **initialZoom** (double?) - Optional - The initial zoom scale factor for the camera. ``` -------------------------------- ### Get Supported Lenses - Dart Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/getSupportedLenses.html This method retrieves the set of supported camera lens types. It's useful for understanding device camera capabilities before scanner initialization. Call this before starting the scanner. ```dart Future> getSupportedLenses() { throw UnimplementedError('getSupportedLenses() has not been implemented.'); } ``` -------------------------------- ### StartOptions Methods Source: https://pub.dev/documentation/gscankit/latest/gscankit/StartOptions-class.html Provides methods for interacting with the StartOptions object. ```APIDOC ## StartOptions Methods ### noSuchMethod(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. ### toMap() → Map Converts this object to a map. ### toString() → String A string representation of this object. ``` -------------------------------- ### StartOptions Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/StartOptions/StartOptions.html Constructs a new StartOptions instance with various configuration options for barcode scanning. ```APIDOC ## StartOptions constructor ### Description Construct a new StartOptions instance. ### Parameters - **cameraDirection** (CameraFacing) - Required - Specifies the camera to use (front or back). - **cameraLensType** (CameraLensType) - Required - Specifies the type of camera lens. - **cameraResolution** (Size?) - Required - The desired resolution for the camera feed. Can be null. - **detectionSpeed** (DetectionSpeed) - Required - The speed at which to perform detection. - **detectionTimeoutMs** (int) - Required - The timeout in milliseconds for detection. - **formats** (List) - Required - A list of barcode formats to scan for. - **returnImage** (bool) - Required - Whether to return the scanned image. - **torchEnabled** (bool) - Required - Whether the torch (flash) should be enabled. - **invertImage** (bool) - Required - Whether to invert the image for scanning. - **autoZoom** (bool) - Required - Whether to enable automatic zoom. - **initialZoom** (double?) - Required - The initial zoom level. Can be null. ### Implementation ```dart const StartOptions({ required this.cameraDirection, required this.cameraLensType, required this.cameraResolution, required this.detectionSpeed, required this.detectionTimeoutMs, required this.formats, required this.returnImage, required this.torchEnabled, required this.invertImage, required this.autoZoom, required this.initialZoom, }); ``` ``` -------------------------------- ### StartOptions Constructor Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/StartOptions/StartOptions.html This is the implementation of the StartOptions constructor. It initializes all required and optional parameters for configuring the scanner. ```dart const StartOptions({ required this.cameraDirection, required this.cameraLensType, required this.cameraResolution, required this.detectionSpeed, required this.detectionTimeoutMs, required this.formats, required this.returnImage, required this.torchEnabled, required this.invertImage, required this.autoZoom, required this.initialZoom, }); ``` -------------------------------- ### Calendar Event Start Property Declaration Source: https://pub.dev/documentation/gscankit/latest/gscankit/CalendarEvent/start.html Declares the nullable DateTime property for the start time of a calendar event. This property is final, meaning it can only be assigned once. ```dart final DateTime? start; ``` -------------------------------- ### ScanWindowUtils() Source: https://pub.dev/documentation/gscankit/latest/gscankit/ScanWindowUtils/ScanWindowUtils.html Initializes a new instance of the ScanWindowUtils class. ```APIDOC ## ScanWindowUtils() ### Description Initializes a new instance of the ScanWindowUtils class. ### Method Constructor ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### buildCameraView method Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/buildCameraView.html Builds and returns a camera preview widget. This method initializes the camera view by calling the platform-specific implementation. ```APIDOC ## buildCameraView() ### Description Build a camera preview widget. ### Signature Widget buildCameraView() ### Implementation ```dart Widget buildCameraView() { _throwIfNotInitialized(); return MobileScannerPlatform.instance.buildCameraView(); } ``` ``` -------------------------------- ### CalendarEvent.fromNative Source: https://pub.dev/documentation/gscankit/latest/gscankit/CalendarEvent/CalendarEvent.fromNative.html Creates a new CalendarEvent instance from a map. The map should contain keys like 'description', 'start', 'end', 'location', 'organizer', 'status', and 'summary'. The 'start' and 'end' values are expected to be strings that can be parsed into DateTime objects. ```APIDOC ## CalendarEvent.fromNative factory constructor ### Description Creates a new CalendarEvent instance from a map. ### Parameters #### Path Parameters - **data** (Map) - Required - A map containing the event details. ### Request Example ```json { "description": "Team Meeting", "start": "2023-10-27T10:00:00Z", "end": "2023-10-27T11:00:00Z", "location": "Conference Room A", "organizer": "john.doe@example.com", "status": "CONFIRMED", "summary": "Discuss project milestones" } ``` ### Response #### Success Response (CalendarEvent Instance) - **description** (String?) - The description of the event. - **start** (DateTime?) - The start date and time of the event. - **end** (DateTime?) - The end date and time of the event. - **location** (String?) - The location of the event. - **organizer** (String?) - The organizer of the event. - **status** (String?) - The status of the event. - **summary** (String?) - A summary of the event. ``` -------------------------------- ### WiFi Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/WiFi/WiFi.html Constructs a new WiFi instance with optional parameters for encryption type, SSID, and password. ```APIDOC ## WiFi constructor ### Description Construct a new WiFi instance. ### Parameters - **encryptionType** (EncryptionType) - Optional - Defaults to EncryptionType.unknown. - **ssid** (String?) - Optional - The network SSID. - **password** (String?) - Optional - The network password. ### Implementation ```dart const WiFi({ this.encryptionType = EncryptionType.unknown, this.ssid, this.password, }); ``` ``` -------------------------------- ### zoomScaleStateStream Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/zoomScaleStateStream.html Get the stream of zoom scale changes. ```APIDOC ## zoomScaleStateStream property Stream get zoomScaleStateStream ### Description Get the stream of zoom scale changes. ### Method getter ### Return Type Stream ``` -------------------------------- ### GalleryButton Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/GalleryButton-class.html Initializes a new instance of the GalleryButton class. ```APIDOC ## GalleryButton ### Description A button that allows the user to pick an image from the gallery and analyze it for barcodes. ### Parameters - **key** (Key?) - Optional - Controls how one widget replaces another widget in the tree. - **onImagePick** (void Function(String?)?) - Optional - Callback function when an image is picked. - **onDetect** (void Function(BarcodeCapture)?) - Optional - Callback function when barcodes are detected. - **validator** (bool Function(BarcodeCapture)?) - Optional - A function to validate detected barcodes. - **controller** (MobileScannerController) - Required - The controller for the mobile scanner. - **isSuccess** (ValueNotifier) - Required - A notifier indicating the success status of the operation. - **text** (String) - Optional - The text to display on the button. Defaults to 'Upload from gallery'. - **icon** (Icon?) - Optional - An icon to display on the button. - **child** (Widget?) - Optional - A child widget to display instead of text and icon. ``` -------------------------------- ### currentTorchMode Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerViewAttributes/currentTorchMode.html Gets the current torch state of the active camera. ```APIDOC ## currentTorchMode Property ### Description The current torch state of the active camera. ### Type TorchState ### Implementation ```dart final TorchState currentTorchMode; ``` ``` -------------------------------- ### Address Constructors Source: https://pub.dev/documentation/gscankit/latest/gscankit/Address-class.html Provides information on how to create new Address instances. ```APIDOC ## Constructors ### Address ```dart Address({List addressLines = const [], AddressType type = AddressType.unknown}) ``` Creates a new Address instance. ### Address.fromNative ```dart Address.fromNative(Map data) ``` Creates a new Address instance from a map. ``` -------------------------------- ### WiFi Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/WiFi-class.html Constructs a new WiFi instance with optional SSID and password, defaulting to unknown encryption type. ```APIDOC ## WiFi Constructor ### Description Constructs a new WiFi instance. ### Signature WiFi({EncryptionType encryptionType = EncryptionType.unknown, String? ssid, String? password}) ``` -------------------------------- ### buildCameraView Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController-class.html Builds the camera preview widget for the scanner. ```APIDOC ## buildCameraView() ### Description Build a camera preview widget. ### Method Widget ``` -------------------------------- ### Get barcodesStream Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/barcodesStream.html This is the default implementation of the barcodesStream getter, indicating that it has not yet been implemented. ```dart Stream get barcodesStream { throw UnimplementedError('barcodesStream has not been implemented.'); } ``` -------------------------------- ### Get Default MobileScannerPlatform Instance Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/instance.html Access the default instance of MobileScannerPlatform. Defaults to MethodChannelMobileScanner. ```dart static MobileScannerPlatform get instance => _instance; ``` -------------------------------- ### GalleryButton Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/GalleryButton/GalleryButton.html Initializes a new instance of the GalleryButton widget with various optional and required parameters. ```APIDOC ## GalleryButton Constructor ### Description Creates a new GalleryButton widget. ### Parameters - **key** (Key?): An optional key for the widget. - **onImagePick** (void Function(String?)?): Callback function triggered when an image is picked from the gallery. - **onDetect** (void Function(BarcodeCapture)?): Callback function triggered when a barcode is detected. - **validator** (bool Function(BarcodeCapture)?): Optional validator function for barcode captures. - **controller** (required MobileScannerController): The mobile scanner controller instance. - **isSuccess** (required ValueNotifier): A ValueNotifier to indicate the success status of an operation. - **text** (String): The text displayed on the button, defaults to 'Upload from gallery'. - **icon** (Icon?): An optional icon to display on the button. - **child** (Widget?): An optional child widget to display instead of text and icon. ``` -------------------------------- ### StartOptions Operators Source: https://pub.dev/documentation/gscankit/latest/gscankit/StartOptions-class.html Defines operators for comparing StartOptions objects. ```APIDOC ## StartOptions Operators ### operator ==(Object other) → bool The equality operator. ``` -------------------------------- ### Get Default Instance Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/instance.html Retrieves the default instance of MobileScannerPlatform. This is typically `MethodChannelMobileScanner` unless overridden. ```APIDOC ## Get Instance ### Description Provides access to the default instance of `MobileScannerPlatform`. ### Method Signature `static MobileScannerPlatform get instance` ### Implementation ```dart static MobileScannerPlatform get instance => _instance; ``` ``` -------------------------------- ### AddressType Property Declaration Source: https://pub.dev/documentation/gscankit/latest/gscankit/Address/type.html This is the declaration of the AddressType property. It is a final property that gets the type of the address. ```dart final AddressType type; ``` -------------------------------- ### WiFi.fromNative Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/WiFi-class.html Constructs a new WiFi instance from a native data map. ```APIDOC ## WiFi.fromNative Constructor ### Description Construct a new WiFi instance from the given `data` map. ### Signature const WiFi.fromNative(Map data) ``` -------------------------------- ### Get Current Torch Mode Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerViewAttributes/currentTorchMode.html Access the currentTorchMode property to retrieve the torch state of the active camera. ```dart final TorchState currentTorchMode; ``` -------------------------------- ### autoStart Property Declaration Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/autoStart.html Declare the autoStart property as a final boolean. This property determines if the scanner starts automatically. ```dart final bool autoStart; ``` -------------------------------- ### Barcode Constructors Source: https://pub.dev/documentation/gscankit/latest/gscankit/Barcode-class.html Information on how to create new Barcode instances. ```APIDOC ## Barcode Constructors ### Barcode() Creates a new Barcode instance with optional parameters for various embedded data types and barcode properties. ### Barcode.fromNative(Map data) Creates a new Barcode instance from a map of native data. ``` -------------------------------- ### Get zoomScaleStateStream Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/zoomScaleStateStream.html This getter returns a stream of double values representing zoom scale changes. It is currently unimplemented. ```dart Stream get zoomScaleStateStream { throw UnimplementedError('zoomScaleStateStream has not been implemented.'); } ``` -------------------------------- ### getSupportedLenses Method Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/getSupportedLenses.html Retrieves the set of supported camera lens types for the current device. This method can be called before starting the scanner. ```APIDOC ## getSupportedLenses() ### Description Get the set of supported camera lens types for the current device. Returns a set of CameraLensType values that are available on the device. Returns an empty set if the device has no cameras. On platforms that do not support querying specific lens types, returns a set containing only CameraLensType.any if cameras are available. This method can be called before starting the scanner. ### Signature Future> getSupportedLenses() ### Returns - A `Future` that resolves to a `Set` representing the available camera lenses. ``` -------------------------------- ### Phone.fromNative Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/Phone-class.html Creates a Phone instance from a map of native data. ```APIDOC ## Phone.fromNative(Map data) ### Description Create a Phone from the given `data`. ### Parameters - **data** (Map) - Required - A map containing the native data for the phone number. ``` -------------------------------- ### GalleryButton Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/GalleryButton/GalleryButton.html Provides the implementation for the GalleryButton widget, initializing its properties from the constructor arguments. ```dart const GalleryButton({ super.key, this.onImagePick, this.onDetect, this.validator, required this.controller, required this.isSuccess, this.text = 'Upload from gallery', this.icon, this.child, }); ``` -------------------------------- ### stop Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/stop.html Stops the camera. The camera can be restarted using start after calling this method. If the camera is already stopped, this method does nothing. ```APIDOC ## stop ### Description Stop the camera. After calling this method, the camera can be restarted using start. Does nothing if the camera is already stopped. ### Signature ```dart Future stop() ``` ``` -------------------------------- ### MobileScannerPlatform Constructor Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/MobileScannerPlatform.html Constructs a MobileScannerPlatform instance. It initializes the platform using a predefined token. ```dart MobileScannerPlatform() : super(token: _token); ``` -------------------------------- ### barcodes property Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/barcodes.html Get the stream of scanned barcodes. If an error occurred during the detection of a barcode, a MobileScannerBarcodeException error is emitted to the stream. ```APIDOC ## barcodes property ### Description Get the stream of scanned barcodes. If an error occurred during the detection of a barcode, a MobileScannerBarcodeException error is emitted to the stream. ### Method Signature Stream get barcodes ### Implementation ```dart Stream get barcodes => _barcodesController.stream; ``` ``` -------------------------------- ### ContactInfo Constructors Source: https://pub.dev/documentation/gscankit/latest/gscankit/ContactInfo-class.html Provides information on how to create new instances of the ContactInfo class. ```APIDOC ## ContactInfo() ### Description Create a new ContactInfo instance. ### Parameters - **addresses** (List
) - Optional - The list of addresses for the person or organisation. - **emails** (List) - Optional - The list of email addresses for the person or organisation. - **name** (PersonName?) - Optional - The name of the contact person. - **organization** (String?) - Optional - The name of the organization. - **phones** (List) - Optional - The available phone numbers for the contact person or organisation. - **title** (String?) - Optional - The contact person's title. - **urls** (List) - Optional - The urls associated with the contact person or organisation. ``` ```APIDOC ## ContactInfo.fromNative(Map data) ### Description Create a new ContactInfo instance from a map. ### Parameters - **data** (Map) - Required - A map containing the data to initialize the ContactInfo object. ``` -------------------------------- ### Get Human-Readable Error Message Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerErrorCode/message.html Returns a human-readable error message for the given MobileScannerErrorCode. Use this to display user-friendly error information. ```dart String get message { switch (this) { case MobileScannerErrorCode.controllerUninitialized: return 'The MobileScannerController has not been initialized. ' 'Call start() before using it.'; case MobileScannerErrorCode.permissionDenied: return 'Camera permission denied.'; case MobileScannerErrorCode.unsupported: return 'Scanning is not supported on this device.'; case MobileScannerErrorCode.controllerAlreadyInitialized: return 'The MobileScannerController is already running. ' 'Stop it before starting again.'; case MobileScannerErrorCode.controllerDisposed: return 'The MobileScannerController was used after it was disposed.'; case MobileScannerErrorCode.controllerInitializing: return 'The MobileScannerController is still initializing. ' 'Await the previous call to start() or disable autoStart before ' 'starting manually.'; case MobileScannerErrorCode.genericError: return 'An unexpected error occurred.'; case MobileScannerErrorCode.controllerNotAttached: return 'The MobileScannerController has not been attached to ' 'MobileScanner. Call start() after the MobileScanner widget is ' 'built.'; } } ``` -------------------------------- ### CalendarEvent Constructors Source: https://pub.dev/documentation/gscankit/latest/gscankit/CalendarEvent-class.html Demonstrates the two ways to create a CalendarEvent instance: directly with properties or from a map of native data. ```APIDOC ## Constructors CalendarEvent({String? description, DateTime? start, DateTime? end, String? location, String? organizer, String? status, String? summary}) Create a new CalendarEvent instance. const CalendarEvent.fromNative(Map data) Create a new CalendarEvent instance from a map. factory ``` -------------------------------- ### Accessing the Barcodes Stream Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/barcodes.html Get the stream of scanned barcodes. If an error occurred during the detection of a barcode, a MobileScannerBarcodeException error is emitted to the stream. ```dart Stream get barcodes => _barcodesController.stream; ``` -------------------------------- ### MobileScannerPlatform Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/MobileScannerPlatform.html Constructs a new instance of MobileScannerPlatform. ```APIDOC ## MobileScannerPlatform() ### Description Constructs a MobileScannerPlatform. ### Method Constructor ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (Instance) - **MobileScannerPlatform** (object) - An initialized MobileScannerPlatform object. ### Response Example N/A ``` -------------------------------- ### onInitstate Property Declaration Source: https://pub.dev/documentation/gscankit/latest/gscankit/GscanKit/onInitstate.html Declare the onInitstate property as a nullable function that can be invoked when the widget initializes. This is useful for performing setup tasks. ```dart final void Function()? onInitstate; ``` -------------------------------- ### ScanWindowPainter Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/ScanWindowPainter-class.html Initializes a new ScanWindowPainter instance with specified properties for the scan window's appearance. ```APIDOC ## ScanWindowPainter Constructor ### Description Constructs a new ScanWindowPainter instance with detailed customization options for the scan window's visual representation. ### Parameters - **borderColor** (Color) - Required - The color for the scan window border. - **borderRadius** (BorderRadius) - Required - The border radius for the scan window and its border. - **borderStrokeCap** (StrokeCap) - Required - The stroke cap for the border around the scan window. - **borderStrokeJoin** (StrokeJoin) - Required - The stroke join for the border around the scan window. - **borderStyle** (PaintingStyle) - Required - The style for the border around the scan window. - **borderWidth** (double) - Required - The width for the border around the scan window. - **color** (Color) - Required - The color for the scan window box. - **scanWindow** (Rect) - Required - The rectangle that defines the scan window. ``` -------------------------------- ### isStarting Property Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerState/isStarting.html This property indicates whether the mobile scanner is currently in the process of starting. It helps prevent duplicate calls to MobileScannerController.start. ```dart final bool isStarting; ``` -------------------------------- ### Build Camera Preview Widget Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/buildCameraView.html Call this method to obtain the camera preview widget. It first checks if the scanner has been initialized. ```dart Widget buildCameraView() { _throwIfNotInitialized(); return MobileScannerPlatform.instance.buildCameraView(); } ``` -------------------------------- ### Address Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/Address/Address.html Creates a new Address instance with optional address lines and type. ```APIDOC ## Address Constructor ### Description Creates a new Address instance. ### Parameters - **addressLines** (List) - Optional - A list of strings representing the address lines. - **type** (AddressType) - Optional - The type of the address, defaults to AddressType.unknown. ### Implementation ```dart const Address({ this.addressLines = const [], this.type = AddressType.unknown, }); ``` ``` -------------------------------- ### Get Available Cameras Count Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerState/availableCameras.html Access the `availableCameras` property to determine the number of cameras. This property is nullable and will be null if the camera count cannot be determined. ```dart final int? availableCameras; ``` -------------------------------- ### Get Torch State Stream Implementation Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerPlatform/torchStateStream.html This snippet shows the default implementation of the torchStateStream getter, which throws an UnimplementedError. It is intended to be overridden by concrete implementations. ```dart Stream get torchStateStream { throw UnimplementedError('torchStateStream has not been implemented.'); } ``` -------------------------------- ### WiFi Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/WiFi/WiFi.html Constructs a new WiFi instance with optional encryption type, SSID, and password. ```dart const WiFi({ this.encryptionType = EncryptionType.unknown, this.ssid, this.password, }); ``` -------------------------------- ### onInitstate Source: https://pub.dev/documentation/gscankit/latest/gscankit/GscanKit/onInitstate.html A callback function that is called when the widget is initialized. ```APIDOC ## onInitstate ### Description A callback function that is called when the widget is initialized. ### Implementation ```dart final void Function()? onInitstate; ``` ``` -------------------------------- ### MobileScannerState.uninitialized() Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerState/MobileScannerState.uninitialized.html Creates a new MobileScannerState instance that is uninitialized. This constructor sets default values for camera and scanner states, indicating that the scanner has not yet been set up or started. ```APIDOC ## MobileScannerState.uninitialized() ### Description Creates a new MobileScannerState instance that is uninitialized. ### Method Constructor ### Endpoint N/A (Dart constructor) ### Parameters None ### Request Example ```dart const scannerState = MobileScannerState.uninitialized(); ``` ### Response #### Success Response An instance of `MobileScannerState` with initial default values. #### Response Example ```dart MobileScannerState( availableCameras: null, cameraDirection: CameraFacing.unknown, cameraLensType: CameraLensType.any, isInitialized: false, isStarting: false, isRunning: false, size: Size.zero, torchState: TorchState.unavailable, deviceOrientation: DeviceOrientation.portraitUp, zoomScale: 1, ) ``` ``` -------------------------------- ### torchEnabled Property Declaration Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/torchEnabled.html This snippet shows the declaration of the torchEnabled property, which is a final boolean. It controls whether the flashlight is turned on when the camera starts. Defaults to false. ```dart final bool torchEnabled; ``` -------------------------------- ### Access Decoded Barcode Bytes Source: https://pub.dev/documentation/gscankit/latest/gscankit/DecodedVisionBarcodeBytes/bytes.html Use the `bytes` property to get the raw, decoded bytes of a barcode. This value is null if header or padding removal fails. ```dart final Uint8List? bytes; ``` -------------------------------- ### copyWith Source: https://pub.dev/documentation/gscankit/latest/gscankit/GscanOverlayConfig/copyWith.html Creates a new GscanOverlayConfig instance, copying all existing values and replacing specified ones. ```APIDOC ## copyWith ### Description Creates a new GscanOverlayConfig instance with the same values as the original, but with the specified fields replaced. This is useful for immutably updating configuration objects. ### Method Signature ```dart GscanOverlayConfig copyWith({ ScannerScanArea? scannerScanArea, ScannerOverlayBackground? scannerOverlayBackground, Color? scannerOverlayBackgroundColor, ScannerBorder? scannerBorder, Color? borderColor, double? borderRadius, double? cornerRadius, double? cornerLength, ScannerBorderPulseEffect? scannerBorderPulseEffect, ScannerLineAnimation? scannerLineAnimation, Color? scannerLineAnimationColor, Duration? scannerLineanimationDuration, double? lineThickness, Cubic? curve, Animation? animation, Widget? background, Color? successColor, Color? errorColor, bool? animateOnSuccess, bool? animateOnError, }) ``` ### Parameters - **scannerScanArea** (ScannerScanArea?) - Optional - The scan area configuration. - **scannerOverlayBackground** (ScannerOverlayBackground?) - Optional - The background configuration for the overlay. - **scannerOverlayBackgroundColor** (Color?) - Optional - The background color of the overlay. - **scannerBorder** (ScannerBorder?) - Optional - The border configuration. - **borderColor** (Color?) - Optional - The color of the border. - **borderRadius** (double?) - Optional - The border radius. - **cornerRadius** (double?) - Optional - The radius of the corners. - **cornerLength** (double?) - Optional - The length of the corners. - **scannerBorderPulseEffect** (ScannerBorderPulseEffect?) - Optional - The pulse effect configuration for the border. - **scannerLineAnimation** (ScannerLineAnimation?) - Optional - The animation configuration for the scan line. - **scannerLineAnimationColor** (Color?) - Optional - The color of the scan line animation. - **scannerLineanimationDuration** (Duration?) - Optional - The duration of the scan line animation. - **lineThickness** (double?) - Optional - The thickness of the scan line. - **curve** (Cubic?) - Optional - The curve for animations. - **animation** (Animation?) - Optional - A generic animation. - **background** (Widget?) - Optional - A custom background widget. - **successColor** (Color?) - Optional - The color to indicate success. - **errorColor** (Color?) - Optional - The color to indicate an error. - **animateOnSuccess** (bool?) - Optional - Whether to animate on success. - **animateOnError** (bool?) - Optional - Whether to animate on error. ### Returns A new `GscanOverlayConfig` instance with the updated properties. ``` -------------------------------- ### Handle controllerNotAttached Error Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerErrorCode.html Demonstrates a common mistake where controller.start() is called before the MobileScanner widget is in the tree, leading to a controllerNotAttached error. This example shows the incorrect approach. ```dart class ScannerExample extends StatefulWidget { const ScannerExample({super.key}); @override State createState() => _ScannerExampleState(); } class _ScannerExampleState extends State { final MobileScannerController controller = MobileScannerController(); bool _showScanner = false; @override void initState() { super.initState(); // The MobileScanner is only in the widget tree after the button is pressed. controller.start(); } @override Widget build(BuildContext context) { return Column( children: [ ElevatedButton( onPressed: () { setState(() { _showScanner = true; }); }, child: const Text('Button'), ), if (_showScanner) Expanded(child: MobileScanner(controller: controller)), ], ); } } ``` -------------------------------- ### BarcodeCapture Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/BarcodeCapture-class.html Creates a new BarcodeCapture instance with a list of barcodes, an optional image, raw data, and the size of the capture. ```APIDOC ## Constructor ### Signature BarcodeCapture({List barcodes = const [], Uint8List? image, Object? raw, Size size = Size.zero}) ### Description Create a new BarcodeCapture instance. ### Parameters - **barcodes** (List) - Optional - The list of scanned barcodes. Defaults to an empty list. - **image** (Uint8List?) - Optional - The input image of the barcode capture. - **raw** (Object?) - Optional - The raw data of the barcode scan. - **size** (Size) - Optional - The raw size of the camera input image, in which the barcodes were detected. Defaults to Size.zero. ``` -------------------------------- ### UrlBookmark Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/UrlBookmark/UrlBookmark.html Constructs a new UrlBookmark instance with a required URL and an optional title. ```APIDOC ## UrlBookmark Constructor ### Description Constructs a new UrlBookmark instance. ### Parameters #### Path Parameters - **url** (String) - Required - The URL for the bookmark. - **title** (String?) - Optional - The title for the bookmark. ### Implementation ```dart const UrlBookmark({required this.url, this.title}); ``` ``` -------------------------------- ### getSupportedLenses Method Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/getSupportedLenses.html Retrieves the set of supported camera lens types for the current device. This method can be called before starting the scanner and may throw a MobileScannerException if the controller has been disposed. ```APIDOC ## getSupportedLenses ### Description Get the set of supported camera lens types for the current device. Returns a set of `CameraLensType` values that are available on the device. This can be used to determine which lens types can be used with the scanner. Returns an empty set if the device has no cameras. On platforms that do not support querying specific lens types, returns a set containing only `CameraLensType.any` if cameras are available. This method can be called before starting the scanner. Throws a `MobileScannerException` if the controller has been disposed. ### Method Signature `Future> getSupportedLenses()` ### Parameters This method does not take any parameters. ### Returns A `Future` that resolves to a `Set` representing the available camera lenses. ### Throws - `MobileScannerException`: If the controller has been disposed. ### Example ```dart final supportedLenses = await controller.getSupportedLenses(); if (supportedLenses.isEmpty) { print('No camera lenses available'); } else { print('Available lenses: $supportedLenses'); } ``` ``` -------------------------------- ### UrlBookmark Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/UrlBookmark-class.html Constructs a new UrlBookmark instance with a required URL and an optional title. ```APIDOC ## UrlBookmark({required String url, String? title}) ### Description Constructs a new UrlBookmark instance. ### Parameters #### Path Parameters - **url** (String) - Required - The URL for the bookmark. - **title** (String?) - Optional - The title for the bookmark. ``` -------------------------------- ### Implementation of getSupportedLenses Source: https://pub.dev/documentation/gscankit/latest/gscankit/MobileScannerController/getSupportedLenses.html This is the internal implementation of the getSupportedLenses method. It checks if the controller has been disposed and throws an exception if it has, otherwise it calls the platform's method to get the supported lenses. ```dart Future> getSupportedLenses() async { if (_isDisposed) { throw MobileScannerException( errorCode: MobileScannerErrorCode.controllerDisposed, errorDetails: MobileScannerErrorDetails( message: MobileScannerErrorCode.controllerDisposed.message, ), ); } return MobileScannerPlatform.instance.getSupportedLenses(); } ``` -------------------------------- ### BarcodeCapture Constructor Source: https://pub.dev/documentation/gscankit/latest/gscankit/BarcodeCapture/BarcodeCapture.html Creates a new BarcodeCapture instance with optional barcode data, image, raw data, and size. ```APIDOC ## BarcodeCapture.new ### Description Create a new BarcodeCapture instance. ### Parameters - **barcodes** (List) - Optional - A list of detected barcodes. - **image** (Uint8List?) - Optional - The image data associated with the barcode capture. - **raw** (Object?) - Optional - Raw data related to the barcode capture. - **size** (Size) - Optional - The size of the captured image, defaults to Size.zero. ```