1

I've doing a project where I use the package google_ml_kit and extract the text from a receipt. I want to label and extract the information like Company name, Cell no., Address, E-mail, Total amount etc. from the receipt. How would I label the texts? Maybe by the use of regex or any other process you know, please tell me the patterns to implement this. I have added my receipt and also my code.

This is the receipt given below:

enter image description here

This is my code given below:

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String _text = "";
  XFile? _xfile;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Text Recognition"),
        actions: [
          TextButton(
            onPressed: scanText,
            child: Text(
              "Scan",
              style: TextStyle(color: Colors.white),
            ),
          ),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: getImage,
        child: Icon(Icons.add_a_photo),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            if (_xfile != null)
              Image.file(
                File(_xfile!.path),
                fit: BoxFit.fitWidth,
              ),
            Text("$_text"),
          ],
        ),
      ),
    );
  }
}

This is what I get after the text extraction:

enter image description here

Mou Biswas
  • 157
  • 2
  • 14

0 Answers0