Search code examples
flutterdartaws-lambdaamazon-dynamodbaws-api-gateway

Show every item in a DynamoDB database in a Flutter app (Dart)


I have a Flutter app which is written in Dart that will become an Android and iOS app. I have a table in a DynamoDB on AWS that I want to show every entry in that table in the Flutter app. It will only be 5 or 10 items in the table as this is a demo for school, not a real app for a business. I have to use AWS and DynamoDB. I have used API Gateway to read an item using the primary key, but I want to show multiple items.

Through my research I am aware of using Lambda to scan the DynamoDB table and then using the API Gateway to connect to the Lambda.

Can anyone help?

I have located a few tutorials and pages about Lambda and querying a DynamoDB, but its unclear how that would make an API Gateway create a http endpoint.


Solution

  • I'll be brief, as it's relatively straight forward, especially as you were already using GetItem. There are two ways to achieve it, one directly from API Gateway to DynamoDB, which I would advise against for you as VTL templates used for this are quite cumbersome.

    The alternative is to use Lambda as a proxy to talk to DynamoDB. You then call DynamoDB Scan API to return all the data in the table:

    1. Set up Lambda proxy integrations in API Gateway
    2. Scan your items