Storing API keys in a JSON file¶
Did you know?
Since Flutter 3.7, you can store all your API keys inside a JSON file and pass it to a new --dart-define-from-file
flag from the command line.
(you’ll want to add that JSON file to .gitignore to avoid exposing your sensitive keys)
Then in your Dart code, simply use String.fromEnvironment
to retrieve your keys and use them as needed. 👇
To learn about different techniques and best practices for storing API keys in Flutter, check out my (updated) article: 👇
Previous | Next |
---|---|
Backend-agnostic Flutter apps | Firebase Auth flow in 5 minutes |
Last update:
18 septembre 2023
Created: 18 septembre 2023
Created: 18 septembre 2023