0

I'm currently trying to learn flutter and implement OCR with firebase ml vision, but currently I want to store the text read to a variable, what's the suggested approach? For example I have a paper with

NAME

INFORMATION

Can I read the first line and store as String variable name and second line as information? How should I implement my for loop here? Let's say I already imported the libraries, and I'm stuck here.

for (TextBlock block in visionText.blocks) {
  for(n=0; n<block.lines.length; n++ )
    {
      name = 
      info =
    }
}

Thanks in advance

salad000
  • 13
  • 5

1 Answers1

0

In your scenario, assuming both name and information take one line each, I would do it the first way:

    for (TextBlock block in visionText.blocks) {
      name = block.lines[0];
      info = block.lines[1];
    }
Victor Eronmosele
  • 7,040
  • 2
  • 10
  • 33
  • 1
    Thanks!! I see that the block.lines is an array itself, I just need to use block.lines[0].text to convert them into string. – salad000 May 22 '21 at 06:41