FlutterFever Studio
Back to packages

Xberg Flutter package guide

Fast, on‑device document intelligence for extracting structured data in Flutter apps.

Install command
Copy and run in your Flutter project
flutter pub add xberg

When to use Xberg

Xberg is a high‑performance, on‑device document intelligence library that brings optical character recognition (OCR), layout analysis, and field extraction directly into your Flutter applications. By converting images, PDFs, or scanned documents into structured data, Xberg removes the manual effort of copying text into forms and enables developers to build smarter, more automated user experiences. The package is written in Dart with native bindings for iOS, Android, Web, macOS, Windows, and Linux, ensuring consistent performance across all Flutter‑supported platforms. Its lightweight core runs entirely offline, which means you can process sensitive documents without sending data to external services, preserving user privacy while still delivering near‑real‑time results.

Use Xberg whenever your app needs to turn physical paperwork into digital input. Typical scenarios include onboarding flows that require a driver's license or passport scan, expense‑tracking tools that parse receipts and invoices, and any form‑heavy application where users can upload photos of documents. By integrating Xberg at the data‑layer of a clean architecture, you can keep the heavy lifting isolated from UI code, allowing state managers like Provider, Riverpod, or Bloc to simply react to the extracted model objects. The library also offers a flexible plugin system so you can swap in custom machine‑learning models if your domain requires specialized field detection beyond the default configuration.

Getting started with Xberg is straightforward. First, add the package with the exact command `flutter pub add xberg`. After the dependency resolves, import the main API and optionally configure platform‑specific permissions (camera, storage, and file access). Xberg provides a single entry point – `XbergProcessor.processDocument()` – that accepts a file path or a `Uint8List` of image bytes and returns a `DocumentResult` containing key‑value pairs, confidence scores, and bounding boxes. The API is asynchronous and streams results, making it easy to display progress indicators while large PDFs are being parsed. For most projects, the default model works out of the box; however, you can enable the `customModelPath` flag to load a TensorFlow Lite model that matches your industry’s terminology.

When moving to production, keep a few considerations in mind. Although Xberg runs locally, the OCR engine can be CPU‑intensive on older devices, so profiling and optional throttling are recommended for low‑end hardware. The package adds roughly 6 MB to the final binary, which is acceptable for most apps but should be accounted for in size‑constrained deployments. Because the library processes user‑provided documents, always validate the extracted data on the server side before persisting it, especially for compliance‑heavy use cases such as KYC or financial reporting. Finally, stay up‑to‑date with the latest version to benefit from model improvements and platform bug fixes.

For beginners, a quick example demonstrates Xberg’s power: a travel‑expense app lets users snap a photo of a receipt, and Xberg instantly fills the amount, date, and merchant fields in the expense form. The UI shows a loading spinner while the image is processed, then presents the auto‑filled form for the user to review and submit. This pattern reduces friction, improves data accuracy, and showcases how Xberg can be combined with any state‑management solution to create a seamless, validation‑ready experience.

auto‑fill forms from photos
invoice and receipt processing
KYC document verification
offline data capture
real‑time field extraction

Pros

  • offline processing
  • cross‑platform support
  • lightweight binary
  • easy API
  • custom model support

Watch outs

  • CPU intensive on low‑end devices
  • adds binary size
  • limited to pre‑trained models unless custom model supplied

Setup notes

Run `flutter pub add xberg` to add the dependency, then execute `flutter pub get`. Import the package with `import 'package:xberg/xberg.dart';`. On mobile platforms, add camera and storage permissions to AndroidManifest.xml and Info.plist. No additional native SDK installation is required.

Requires Flutter 3.0+ and Dart 2.17+. Supports Android, iOS, Web, macOS, Windows, and Linux. Works with null‑safety enabled projects.

import 'package:flutter/material.dart';
import 'package:xberg/xberg.dart';

class ReceiptScanner extends StatefulWidget {
  const ReceiptScanner({Key? key}) : super(key: key);
  @override
  _ReceiptScannerState createState() => _ReceiptScannerState();
}

class _ReceiptScannerState extends State<ReceiptScanner> {
  final _processor = XbergProcessor();
  Map<String, dynamic>? _result;

  Future<void> _scanDocument() async {
    final file = await pickImage(); // implement image picker separately
    final doc = await _processor.processDocument(file.path);
    setState(() => _result = doc.fields);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Receipt Scanner')),
      body: Center(
        child: _result == null
            ? ElevatedButton(onPressed: _scanDocument, child: const Text('Scan Receipt'))
            : Column(
                mainAxisSize: MainAxisSize.min,
                children: _result!.entries.map((e) => Text('${e.key}: ${e.value}')).toList(),
              ),
      ),
    );
  }
}

Official package resources