Skip to content

Instantly share code, notes, and snippets.

View bmishkin's full-sized avatar
🎯
Focusing

Ben Mishkin bmishkin

🎯
Focusing
  • Anthem.AI
  • Austin, TX
  • 14:34 (UTC -05:00)
View GitHub Profile
@VincentH-Net
VincentH-Net / UseOpenApiInFlutter.md
Last active April 15, 2025 09:56
Use OpenApi in Flutter

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.json file on build from an ASP.NET 8 Minimal API project

  1. Create a new Flutter 3.10 (or later) Application project in Visual Studio Code: steps
  2. 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 the dependencies section of your pubspec.yaml file :
      dependencies:
        openapi_generator_annotations: ^4.10.0
# lazyload nvm
# all props goes to http://broken-by.me/lazy-load-nvm/
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/
lazynvm() {
unset -f nvm node npm npx
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
if [ -f "$NVM_DIR/bash_completion" ]; then
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion