To generate an API client in Dart from an OpenApi.json file, and use it in Flutter, follow these steps:
Related: see this gist for how to generate an
OpenApi.jsonfile on build from an ASP.NET 8 Minimal API project
- Create a new Flutter 3.10 (or later)
Applicationproject in Visual Studio Code: steps - Add the openapi_generator package to your project. Follow below steps instead of the instructions at pub.dev (at the time of writing they were out of date):
- Include
openapi_generator_annotationsin thedependenciessection of yourpubspec.yamlfile :dependencies: openapi_generator_annotations: ^4.10.0
- Include