<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adhil Latheef on Medium]]></title>
        <description><![CDATA[Stories by Adhil Latheef on Medium]]></description>
        <link>https://medium.com/@adhillatheeflas?source=rss-148ae81c436c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*irEwCA0LhCkrOW_l45imSw.jpeg</url>
            <title>Stories by Adhil Latheef on Medium</title>
            <link>https://medium.com/@adhillatheeflas?source=rss-148ae81c436c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 04:25:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adhillatheeflas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Stop Typing What’s Already on the Screen: Selectable OCR in Flutter]]></title>
            <link>https://medium.com/@adhillatheeflas/stop-typing-whats-already-on-the-screen-selectable-ocr-in-flutter-db5d01f4ab2b?source=rss-148ae81c436c------2</link>
            <guid isPermaLink="false">https://medium.com/p/db5d01f4ab2b</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Adhil Latheef]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 05:29:36 GMT</pubDate>
            <atom:updated>2026-10-09T05:29:36.314Z</atom:updated>
            <content:encoded><![CDATA[<p>9 Oct 2026 · <a href="https://medium.com/u/148ae81c436c">Adhil Latheef</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vktq5t3luDl2tAY4kd6bXQ.gif" /><figcaption>Extracting Data From Date of Birth</figcaption></figure><h3>The problem: retyping what’s already on the screen</h3><p>Every onboarding flow I’ve built has the same weak spot. The user’s data is already in front of them, on a passport, an invoice, or a shipping label, and we still ask them to type it in by hand.</p><p>Typing is slow, and it’s where mistakes creep in. A transposed digit in a passport number or a misspelled surname can fail a KYC check and send a support ticket your way.</p><p>The usual fix is to run OCR on the whole page. That gives you every line of text with no idea which line is the surname and which is the place of birth. You end up writing fragile parsing rules, or asking the user to fix the result anyway.</p><p>I wanted something simpler: let the user point at the exact text they mean, and give me just that text.</p><h3>The idea: draw a box, get the text</h3><p><strong>selectable_ocr</strong> is an open-source Flutter package built around one gesture. The user draws a rectangle over any part of your UI, and the package returns the text inside it.</p><p>It grew out of my earlier package, <a href="https://pub.dev/packages/selectable_area">selectable_area</a>, which lets users select a region of any widget and capture it as an image. In a previous article, <a href="https://medium.com/@adhillatheeflas/stop-screenshotting-a-better-way-to-capture-ui-in-flutter-fd994de69737">Stop Screenshotting</a>, I paired it with PyTesseract on a server to read the captured region.</p><p>That worked, but it needed a backend for every scan. selectable_ocr removes that step. Selection and text recognition now live in one widget, and recognition runs on the device by default.</p><h3>Getting started in five minutes</h3><p>Add the package to your pubspec.yaml:</p><pre>dependencies:<br>  selectable_ocr: ^1.0.0</pre><p>Then run flutter pub get. On Android, set minSdkVersion to 21. No camera or storage permissions are needed, because the widget reads pixels that are already rendered on screen.</p><p>Wrap any widget in SelectableOcr and listen for the result:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:selectable_ocr/selectable_ocr.dart&#39;;</pre><pre>class SimpleOcrView extends StatelessWidget {<br>  const SimpleOcrView({super.key});</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: const Text(&#39;Snip &amp; OCR&#39;)),<br>      body: Center(<br>        child: SelectableOcr(<br>          child: Image.network(&#39;https://example.com/document.png&#39;),<br>          onTextExtracted: (String text) {<br>            ScaffoldMessenger.of(context).showSnackBar(<br>              SnackBar(content: Text(&#39;Extracted: $text&#39;)),<br>            );<br>          },<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>That’s the whole integration. The user drags a box over the image, a small badge shows while it’s processing, and onTextExtracted receives the text.</p><h3>A real example: filling a passport form field by field</h3><p>The demo below shows the pattern I built this for. A passport sits on the left and a form on the right. The user picks a field, draws a box around that value on the document, and the field fills itself and gets a check mark.</p><p><em>[Embed the demo video or GIF here]</em></p><p>The trick is to keep track of which field is active and route each extracted text into it:</p><pre>class PassportFormPage extends StatefulWidget {<br>  const PassportFormPage({super.key});</pre><pre>  @override<br>  State&lt;PassportFormPage&gt; createState() =&gt; _PassportFormPageState();<br>}</pre><pre>class _PassportFormPageState extends State&lt;PassportFormPage&gt; {<br>  final fields = [&#39;Surname&#39;, &#39;Given Name&#39;, &#39;Date of Birth&#39;, &#39;Place of Birth&#39;, &#39;Date of Expiry&#39;];<br>  final controllers = &lt;String, TextEditingController&gt;{};<br>  String? activeField;</pre><pre>  @override<br>  void initState() {<br>    super.initState();<br>    for (final f in fields) {<br>      controllers[f] = TextEditingController();<br>    }<br>    activeField = fields.first;<br>  }</pre><pre>  void _fill(String text) {<br>    if (activeField == null) return;<br>    setState(() {<br>      controllers[activeField]!.text = text.trim();<br>      // Move to the next empty field automatically<br>      activeField = fields.firstWhere(<br>        (f) =&gt; controllers[f]!.text.isEmpty,<br>        orElse: () =&gt; activeField!,<br>      );<br>    });<br>  }</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return Row(<br>      children: [<br>        Expanded(<br>          child: SelectableOcr(<br>            child: Image.asset(&#39;assets/passport.png&#39;),<br>            onTextExtracted: _fill,<br>          ),<br>        ),<br>        Expanded(<br>          child: ListView(<br>            children: [<br>              for (final f in fields)<br>                ListTile(<br>                  title: TextField(<br>                    controller: controllers[f],<br>                    decoration: InputDecoration(labelText: f),<br>                  ),<br>                  selected: f == activeField,<br>                  onTap: () =&gt; setState(() =&gt; activeField = f),<br>                ),<br>            ],<br>          ),<br>        ),<br>      ],<br>    );<br>  }<br>}</pre><p>The user stays in control of what goes where, so there’s no parsing logic and no guessing. Every value is still an editable text field, which lets them correct a misread before submitting.</p><h3>Under the hood</h3><p>When the user finishes drawing, the package captures only the selected region of the rendered widget as an image. It then hands that image to an OCR engine.</p><p>By default, that engine runs on the device using Google ML Kit. This has three practical benefits:</p><ul><li><strong>No backend.</strong> There’s no server to deploy, no API keys, and no per-request cost.</li><li><strong>Privacy.</strong> The image never leaves the device, which matters for passports, IDs, and medical forms.</li><li><strong>Speed.</strong> Recognition typically finishes in about 50–120 ms, so it feels instant.</li></ul><p>Because only a small region is processed, rather than the whole page, recognition is both faster and more accurate.</p><p>You can switch the script for non-Latin text, including Devanagari, Chinese, Japanese, and Korean:</p><pre>SelectableOcr(<br>  engine: OnDeviceOcrEngine(<br>    script: TextRecognitionScript.devanagari,<br>  ),<br>  child: myImageWidget,<br>  onTextExtracted: (text) =&gt; print(text),<br>)</pre><p>Sometimes you need your own OCR, such as a fine-tuned model, a cloud service, or support for platforms ML Kit doesn’t cover. For that, HttpOcrEngine sends the cropped image to any endpoint you choose:</p><pre>SelectableOcr(<br>  engine: HttpOcrEngine(<br>    endpoint: Uri.parse(&#39;https://your-api.example.com/ocr&#39;),<br>    headers: {&#39;Authorization&#39;: &#39;Bearer YOUR_TOKEN&#39;},<br>    timeout: const Duration(seconds: 10),<br>  ),<br>  child: myWidget,<br>  onTextExtracted: (text) =&gt; print(&#39;Server extracted: $text&#39;),<br>)</pre><p>The selection experience stays the same whichever engine you use. Only the recognition step changes.</p><h3>Make it yours</h3><p>The selection box and loading badge can be styled to match your app:</p><pre>SelectableOcr(<br>  style: const SelectionStyle(<br>    strokeColor: Colors.purpleAccent,<br>    fillColor: Color(0x33AB47BC),<br>    strokeWidth: 2.5,<br>    cornerRadius: 8.0,<br>    showLoadingBadge: true,<br>    loadingText: &#39;Scanning receipt...&#39;,<br>    loadingBadgeColor: Colors.purpleAccent,<br>  ),<br>  child: myReceiptWidget,<br>  onTextExtracted: (text) =&gt; print(text),<br>)</pre><p>If you need more than a plain string, use onOcrResult. It returns an OcrResult with the cleaned text, each recognized line, and how long recognition took. onImageCaptured gives you the cropped PNG bytes, which is handy for audit trails or attaching proof to a record:</p><pre>SelectableOcr(<br>  child: myDocumentWidget,<br>  onOcrResult: (OcrResult result) {<br>    print(&#39;Text: ${result.cleanText}&#39;);<br>    print(&#39;Took: ${result.processingTime.inMilliseconds} ms&#39;);<br>    print(&#39;Lines: ${result.lines.length}&#39;);<br>  },<br>  onImageCaptured: (Uint8List pngBytes) {<br>    // Save or upload the cropped region<br>  },<br>)</pre><h3>Where it fits, and what’s next</h3><p>This pattern helps anywhere users copy data from a document into a form:</p><ul><li><strong>KYC and onboarding:</strong> passports, national IDs and driving licences</li><li><strong>Finance:</strong> invoice numbers, totals and dates from receipts</li><li><strong>Logistics:</strong> tracking numbers and addresses from shipping labels</li><li><strong>Healthcare and admin:</strong> reference numbers from scanned forms</li></ul><p>Next, I want to add more examples to the repository and keep improving accuracy on tricky inputs. If there’s a use case you’d like supported, open an issue and tell me about it.</p><p>The package is MIT-licensed and available on pub.dev:</p><p><a href="https://pub.dev/packages/selectable_ocr"><strong>pub.dev/packages/selectable_ocr</strong></a></p><p>If it saves you some typing, a like on pub.dev helps other developers find it. Feedback, issues, and pull requests are all welcome.</p><p><em>Thanks for reading. I’m Adhil, a Senior Flutter Developer who builds production mobile and web apps. You can find me on </em><a href="https://www.linkedin.com/in/adhil-latheef/"><em>LinkedIn</em></a><em> and </em><a href="https://github.com/adhillatheef"><em>GitHub</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db5d01f4ab2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Screenshotting: A Better Way to Capture UI in Flutter]]></title>
            <link>https://medium.com/@adhillatheeflas/stop-screenshotting-a-better-way-to-capture-ui-in-flutter-fd994de69737?source=rss-148ae81c436c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd994de69737</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[ocr]]></category>
            <dc:creator><![CDATA[Adhil Latheef]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 11:06:07 GMT</pubDate>
            <atom:updated>2025-09-14T11:06:07.610Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A full-stack guide to building an interactive document data extraction tool with my Flutter package, selectable_area, and a Python backend.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*5DC8sozea1W0i72aGaB7NQ.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*f1vPVM0-7V9NVhTLDYGeqA.gif" /></figure><p>As Flutter developers, we spend countless hours crafting beautiful user interfaces. But what happens when we need to let our users interact with that UI more dynamically? I’m not just talking about tapping buttons, but actually selecting, cropping, and capturing a specific part of the screen.</p><p>The classic solution is a clunky workflow: take a screenshot, open an editor, crop it, save it, and upload it. It’s slow, inefficient, and a terrible user experience.</p><p>I knew there had to be a better way. This led me to create <a href="https://www.google.com/search?q=https://pub.dev/packages/selectable_area"><strong>selectable_area</strong></a>, a Flutter package designed to do one thing incredibly well: let you select and capture any part of your UI as an image.</p><p>This article isn’t just about my package; it’s a full-stack tutorial showing you how to use it to build a powerful, real-world document scanning app from scratch.</p><h3>What is selectable_area?</h3><p>At its core, selectable_area is a simple but powerful wrapper widget. You can place it around any widget in your tree—anImage, aColumn, a complex ListView—and it instantly makes that area selectable.</p><p>When the user draws a rectangle over the content, the widget returns the captured portion as an image, ready for whatever you need to do next.</p><h3>The Possibilities Are Endless</h3><p>While I built it for a document-scanning project, the use cases are vast:</p><ul><li><strong>Profile Picture Cropping</strong>: Let users select the perfect frame from a larger photo.</li><li><strong>Digital Whiteboards</strong>: Allow users to snip a portion of a canvas to save or share.</li><li><strong>Data Extraction from Receipts</strong>: Snip just the total amount from a photo of a receipt.</li><li><strong>Educational Apps</strong>: Let students highlight and save diagrams or text snippets.</li><li><strong>Bug Reporting Tools</strong>: Allow users to select the exact part of the UI where they found an issue.</li></ul><p>Now, let’s put it to the test and build something beneficial.</p><h3>Let’s Build a Real-World App: An Interactive Document Scanner</h3><p>We’re going to create a web app where a user can upload a passport image and extract data fields like “Name” and “Date of Birth” simply by drawing a box around them.</p><p>To do this, we’ll need a simple backend that can perform Optical Character Recognition (OCR).</p><h3>Part 1: The Backend (Your Personal OCR Engine)</h3><p>We’ll build a lightweight API using Python and the powerful Tesseract OCR engine.</p><p><strong>Prerequisites</strong>: Before you start, make sure you have <a href="https://www.python.org/downloads/">Python</a> and <a href="https://brew.sh/">Homebrew</a> installed on your Mac.</p><h4>Step 1: Setting up the Environment</h4><ol><li><strong>Install Tesseract Engine:</strong> Open your terminal and run:</li></ol><pre>brew install tesseract</pre><p><strong>2. Create a Project &amp; Virtual Environment:</strong></p><pre>mkdir ocr_api &amp;&amp; cd ocr_api python3 -m venv venv source venv/bin/activate</pre><p><strong>3. Install Required Libraries:</strong></p><pre>pip install Flask pytesseract Pillow flask-cors</pre><h4>Step 2: Writing the API Code</h4><p>Create a file named api.py. This script will start a local web server that waits for an image, runs OCR on it, and sends back the text.</p><pre># api.py<br>import base64<br>import io<br>from flask import Flask, request, jsonify<br>from flask_cors import CORS<br>from PIL import Image<br>import pytesseract<br>app = Flask(__name__)<br>CORS(app) # This is crucial for connecting from a web app<br>@app.route(&#39;/ocr&#39;, methods=[&#39;POST&#39;])<br>def perform_ocr():<br>    if not request.json or &#39;base64_image&#39; not in request.json:<br>        return jsonify({&#39;error&#39;: &#39;Missing base64_image in request&#39;}), 400<br>base64_string = request.json[&#39;base64_image&#39;]<br>try:<br>        image_bytes = base64.b64decode(base64_string)<br>        image = Image.open(io.BytesIO(image_bytes))<br>        extracted_text = pytesseract.image_to_string(image)<br>        return jsonify({&#39;extracted_text&#39;: extracted_text.strip()})<br>    except Exception as e:<br>        return jsonify({&#39;error&#39;: str(e)}), 500<br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;0.0.0.0&#39;, port=5000, debug=True)</pre><p>Run the server from your terminal with python api.py. Your OCR backend is now live!</p><h3>Part 2: The Frontend (The Flutter Web App)</h3><p>Now for the fun part. Let’s build the user interface.</p><h4>Step 1: Project Setup</h4><p>In your Flutter project, add the necessary dependencies to your pubspec.yaml:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  <br>  selectable_area: ^1.0.1 # Use your latest version<br>  http: ^1.2.1</pre><h4>Step 2: Building the UI</h4><p>We’ll create a two-pane layout. On the left, the document viewer is being used SelectableArea. On the right, a list of TextFields the data we want to extract.</p><p>The user flow is intuitive:</p><ol><li>Click TextField on the right to make it &quot;active&quot;.</li><li>Draw a box around the corresponding text on the document image.</li><li>The extracted text from our API magically appears in the active field.</li></ol><p>Here’s a simplified look at the UI code</p><pre>// ... state variables for controllers, active field index, etc.<br>Row(<br>  children: [<br>    // Left Pane: Document Viewer<br>    Expanded(<br>      flex: 3,<br>      child: SelectableArea(<br>        outputType: SelectionOutputType.base64,<br>        onSelectionEnd: _handleSelection, // Our function that calls the API<br>        child: Image.network(&#39;https://.../passport_image.jpg&#39;),<br>      ),<br>    ),<br>    // Right Pane: Data Fields<br>    SizedBox(<br>      width: 400,<br>      child: ListView.builder(<br>        itemCount: fields.length,<br>        itemBuilder: (context, index) {<br>          return TextField(<br>            controller: fields[index].controller,<br>            onTap: () =&gt; setState(() =&gt; _activeFieldIndex = index),<br>            // ... other styling<br>          );<br>        },<br>      ),<br>    ),<br>  ],<br>)</pre><h4>Step 3: Connecting to the API</h4><p>The _handleSelection Function is the bridge between our front-end and back-end. It takes the captured image data from SelectableArea and sends it to our Python API.</p><pre>// Inside your screen&#39;s State class<br>void _handleSelection(dynamic selectionResult) async {<br>  if (_activeFieldIndex == null) {<br>    // Show an error: a field must be selected first<br>    return;<br>  }<br>  <br>  setState(() =&gt; _isLoading = true);<br>try {<br>    final response = await http.post(<br>      // For web, use localhost. For mobile, use your computer&#39;s IP.<br>      Uri.parse(&#39;http://localhost:5000/ocr&#39;),<br>      headers: {&#39;Content-Type&#39;: &#39;application/json&#39;},<br>      body: jsonEncode({&#39;base64_image&#39;: selectionResult}),<br>    );<br>if (response.statusCode == 200) {<br>      final data = jsonDecode(response.body);<br>      final text = data[&#39;extracted_text&#39;] ?? &#39;&#39;;<br>      <br>      // Update the active text field with the result!<br>      setState(() {<br>        _fields[_activeFieldIndex!].controller.text = text;<br>      });<br>    }<br>  } catch (e) {<br>    // Handle connection errors<br>  } finally {<br>    setState(() =&gt; _isLoading = false);<br>  }<br>}</pre><p><strong>The Full Flutter Code</strong></p><p>The following is the complete code for lib/main.dart. It contains the UI, state management, and the logic to connect to the Python API we just built.</p><pre>// lib/main.dart<br>import &#39;dart:convert&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>import &#39;package:selectable_area/selectable_area.dart&#39;;<br><br>// --- Configuration ---<br>const String localApiUrl = &#39;http://localhost:5000/ocr&#39;;<br>// --------------------<br><br>void main() {<br>  runApp(const OcrWebApp());<br>}<br><br>// A simple data class to hold information for each text field.<br>class FieldData {<br>  final String label;<br>  final TextEditingController controller;<br>  bool isValidated;<br><br>  FieldData({required this.label, required this.controller, this.isValidated = false});<br>}<br><br>class OcrWebApp extends StatelessWidget {<br>  const OcrWebApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      title: &#39;Document OCR Tool&#39;,<br>      theme: ThemeData(<br>        brightness: Brightness.dark,<br>        primaryColor: Colors.blueAccent,<br>        scaffoldBackgroundColor: const Color(0xFF1a1c23),<br>        cardColor: const Color(0xFF252831),<br>        fontFamily: &#39;Inter&#39;,<br>      ),<br>      home: const OcrScreen(),<br>    );<br>  }<br>}<br><br>class OcrScreen extends StatefulWidget {<br>  const OcrScreen({super.key});<br><br>  @override<br>  State&lt;OcrScreen&gt; createState() =&gt; _OcrScreenState();<br>}<br><br>class _OcrScreenState extends State&lt;OcrScreen&gt; {<br>  int? _activeFieldIndex;<br>  bool _isLoading = false;<br>  String _statusMessage = &#39;Select a field on the right to begin.&#39;;<br>  late final List&lt;FieldData&gt; _fields;<br><br>  @override<br>  void initState() {<br>    super.initState();<br>    _fields = [<br>      FieldData(label: &#39;Passport No&#39;, controller: TextEditingController()),<br>      FieldData(label: &#39;Surname&#39;, controller: TextEditingController()),<br>      FieldData(label: &#39;Given Name&#39;, controller: TextEditingController()),<br>      FieldData(label: &#39;Date of Birth&#39;, controller: TextEditingController()),<br>      FieldData(label: &#39;Place of Birth&#39;, controller: TextEditingController()),<br>      FieldData(label: &#39;Date of Expiry&#39;, controller: TextEditingController()),<br>    ];<br>  }<br><br>  @override<br>  void dispose() {<br>    for (var field in _fields) {<br>      field.controller.dispose();<br>    }<br>    super.dispose();<br>  }<br><br>  void _handleSelection(dynamic selectionResult) async {<br>    if (_activeFieldIndex == null) {<br>      setState(() =&gt; _statusMessage = &#39;Error: Please select a field first!&#39;);<br>      return;<br>    }<br>    String base64Image = selectionResult as String;<br>    setState(() {<br>      _isLoading = true;<br>      _statusMessage = &#39;Processing OCR for &quot;${_fields[_activeFieldIndex!].label}&quot;...&#39;;<br>    });<br><br>    try {<br>      final response = await http.post(<br>        Uri.parse(localApiUrl),<br>        headers: {&#39;Content-Type&#39;: &#39;application/json&#39;},<br>        body: jsonEncode({&#39;base64_image&#39;: base64Image}),<br>      );<br><br>      if (response.statusCode == 200) {<br>        final data = jsonDecode(response.body);<br>        final String extractedText = data[&#39;extracted_text&#39;] ?? &#39;&#39;;<br>        setState(() {<br>          _fields[_activeFieldIndex!].controller.text = extractedText;<br>          _fields[_activeFieldIndex!].isValidated = true;<br>          _statusMessage = &#39;Success! Extracted: &quot;${extractedText.trim()}&quot;&#39;;<br>          if (_activeFieldIndex! &lt; _fields.length - 1) {<br>            _activeFieldIndex = _activeFieldIndex! + 1;<br>          } else {<br>            _activeFieldIndex = null;<br>          }<br>        });<br>      } else {<br>        setState(() =&gt; _statusMessage = &#39;API Error: ${response.statusCode}&#39;);<br>      }<br>    } catch (e) {<br>      setState(() =&gt; _statusMessage = &#39;Connection Error. Is the API running?&#39;);<br>    } finally {<br>      setState(() =&gt; _isLoading = false);<br>    }<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Center(<br>        child: Padding(<br>          padding: const EdgeInsets.all(24.0),<br>          child: Row(<br>            crossAxisAlignment: CrossAxisAlignment.start,<br>            children: [<br>              Expanded(flex: 3, child: _buildDocumentViewer()),<br>              const SizedBox(width: 24),<br>              SizedBox(width: 400, child: _buildDataFields()),<br>            ],<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br><br>  Widget _buildDocumentViewer() {<br>    return Card(<br>      elevation: 8,<br>      clipBehavior: Clip.antiAlias,<br>      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),<br>      child: SelectableArea(<br>        outputType: SelectionOutputType.base64,<br>        onSelectionEnd: _handleSelection,<br>        child: Image.network(<br>          &#39;[https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Indonesian_Passport_Biodata_Page.jpg/1280px-Indonesian_Passport_Biodata_Page.jpg](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Indonesian_Passport_Biodata_Page.jpg/1280px-Indonesian_Passport_Biodata_Page.jpg)&#39;,<br>          fit: BoxFit.contain,<br>        ),<br>      ),<br>    );<br>  }<br><br>  Widget _buildDataFields() {<br>    return Container(<br>      padding: const EdgeInsets.all(24),<br>      decoration: BoxDecoration(<br>        color: Theme.of(context).cardColor,<br>        borderRadius: BorderRadius.circular(12),<br>      ),<br>      child: Column(<br>        crossAxisAlignment: CrossAxisAlignment.stretch,<br>        children: [<br>          Expanded(child: _buildFieldsList()),<br>          const SizedBox(height: 16),<br>          SizedBox(height: 40, child: _buildStatusArea()),<br>          const SizedBox(height: 16),<br>          ElevatedButton(onPressed: () {}, child: const Text(&#39;Confirm&#39;)),<br>        ],<br>      ),<br>    );<br>  }<br><br>  ListView _buildFieldsList() {<br>    return ListView.builder(<br>      itemCount: _fields.length,<br>      itemBuilder: (context, index) {<br>        final field = _fields[index];<br>        final bool isActive = _activeFieldIndex == index;<br>        return Padding(<br>          padding: const EdgeInsets.only(bottom: 16.0),<br>          child: TextField(<br>            controller: field.controller,<br>            onTap: () =&gt; setState(() {<br>              _activeFieldIndex = index;<br>              _statusMessage = &#39;Now select &quot;${field.label}&quot; on the document.&#39;;<br>            }),<br>            decoration: InputDecoration(<br>              labelText: field.label,<br>              filled: true,<br>              fillColor: isActive ? Colors.blueAccent.withOpacity(0.1) : null,<br>              suffixIcon: field.isValidated ? const Icon(Icons.check_circle, color: Colors.green) : null,<br>            ),<br>          ),<br>        );<br>      },<br>    );<br>  }<br><br>  Widget _buildStatusArea() {<br>    return _isLoading<br>        ? const Center(child: CircularProgressIndicator())<br>        : Center(<br>            child: Text(<br>              _statusMessage,<br>              textAlign: TextAlign.center,<br>              style: TextStyle(color: Colors.grey[400]),<br>            ),<br>          );<br>  }<br>}</pre><p><strong>The Final Result &amp; What I Learned</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vktq5t3luDl2tAY4kd6bXQ.gif" /></figure><p>After putting all the pieces together, we have a seamless, interactive document scanning experience. The user never has to leave the app, and the process of extracting data becomes incredibly fast and intuitive.</p><p>Building selectable_area was more than just solving a technical problem; it was a reminder of the power of the open-source community. By creating focused, reusable tools, we can all help each other build better, more powerful applications.</p><p>I’d be thrilled if you gave the package a try. You can find it on <a href="https://www.google.com/search?q=https://pub.dev/packages/selectable_area"><strong>pub.dev</strong></a> and check out the source code on <a href="https://www.google.com/search?q=https://github.com/adhillatheef/selectable_area"><strong>GitHub</strong></a>.</p><p>What will you build with it?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd994de69737" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>