analyzeDocument method
- required Document document,
- required List<FeatureType> featureTypes,
- HumanLoopConfig? humanLoopConfig,
Analyzes an input document for relationships between detected items.
The types of information returned are as follows:
- 
Form data (key-value pairs). The related information is returned in two
Block objects, each of type KEY_VALUE_SET: a KEYBlockobject and a VALUEBlockobject. For example, Name: Ana Silva Carolina contains a key and value. Name: is the key. Ana Silva Carolina is the value.
- 
Table and table cell data. A TABLE Blockobject contains information about a detected table. A CELLBlockobject is returned for each cell in a table.
- 
Lines and words of text. A LINE Blockobject contains one or more WORDBlockobjects. All lines and words that are detected in the document are returned (including text that doesn't have a relationship with the value ofFeatureTypes).
Block object contains information about a selection element,
including the selection status.
You can choose which type of analysis to perform by specifying the
FeatureTypes list.
The output is returned in a list of Block objects.
AnalyzeDocument is a synchronous operation. To analyze
documents asynchronously, use StartDocumentAnalysis.
For more information, see Document Text Analysis.
May throw InvalidParameterException. May throw InvalidS3ObjectException. May throw UnsupportedDocumentException. May throw DocumentTooLargeException. May throw BadDocumentException. May throw AccessDeniedException. May throw ProvisionedThroughputExceededException. May throw InternalServerError. May throw ThrottlingException. May throw HumanLoopQuotaExceededException.
Parameter document :
The input document as base64-encoded bytes or an Amazon S3 object. If you
use the AWS CLI to call Amazon Textract operations, you can't pass image
bytes. The document must be an image in JPEG or PNG format.
If you're using an AWS SDK to call Amazon Textract, you might not need to
base64-encode image bytes that are passed using the Bytes
field.
Parameter featureTypes :
A list of the types of analysis to perform. Add TABLES to the list to
return information about the tables that are detected in the input
document. Add FORMS to return detected form data. To perform both types of
analysis, add TABLES and FORMS to FeatureTypes. All lines and
words detected in the document are included in the response (including
text that isn't related to the value of FeatureTypes).
Parameter humanLoopConfig :
Sets the configuration for the human in the loop workflow for analyzing
documents.
Implementation
Future<AnalyzeDocumentResponse> analyzeDocument({
  required Document document,
  required List<FeatureType> featureTypes,
  HumanLoopConfig? humanLoopConfig,
}) async {
  ArgumentError.checkNotNull(document, 'document');
  ArgumentError.checkNotNull(featureTypes, 'featureTypes');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Textract.AnalyzeDocument'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Document': document,
      'FeatureTypes': featureTypes.map((e) => e.toValue()).toList(),
      if (humanLoopConfig != null) 'HumanLoopConfig': humanLoopConfig,
    },
  );
  return AnalyzeDocumentResponse.fromJson(jsonResponse.body);
}